MCPcopy Create free account
hub / github.com/F-Stack/f-stack / udp_getcred

Function udp_getcred

freebsd/netinet/udp_usrreq.c:927–961  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

925
926#ifdef INET
927static int
928udp_getcred(SYSCTL_HANDLER_ARGS)
929{
930 struct xucred xuc;
931 struct sockaddr_in addrs[2];
932 struct epoch_tracker et;
933 struct inpcb *inp;
934 int error;
935
936 error = priv_check(req->td, PRIV_NETINET_GETCRED);
937 if (error)
938 return (error);
939 error = SYSCTL_IN(req, addrs, sizeof(addrs));
940 if (error)
941 return (error);
942 NET_EPOCH_ENTER(et);
943 inp = in_pcblookup(&V_udbinfo, addrs[1].sin_addr, addrs[1].sin_port,
944 addrs[0].sin_addr, addrs[0].sin_port,
945 INPLOOKUP_WILDCARD | INPLOOKUP_RLOCKPCB, NULL);
946 NET_EPOCH_EXIT(et);
947 if (inp != NULL) {
948 INP_RLOCK_ASSERT(inp);
949 if (inp->inp_socket == NULL)
950 error = ENOENT;
951 if (error == 0)
952 error = cr_canseeinpcb(req->td->td_ucred, inp);
953 if (error == 0)
954 cru2x(inp->inp_cred, &xuc);
955 INP_RUNLOCK(inp);
956 } else
957 error = ENOENT;
958 if (error == 0)
959 error = SYSCTL_OUT(req, &xuc, sizeof(struct xucred));
960 return (error);
961}
962
963SYSCTL_PROC(_net_inet_udp, OID_AUTO, getcred,
964 CTLTYPE_OPAQUE | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_MPSAFE,

Callers

nothing calls this directly

Calls 4

in_pcblookupFunction · 0.85
cr_canseeinpcbFunction · 0.70
priv_checkFunction · 0.50
cru2xFunction · 0.50

Tested by

no test coverage detected