diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-06-06 07:10:13 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-06-06 07:10:13 +0000 |
commit | 10924736bc15015bfe56de18b45f7e62311f1778 (patch) | |
tree | f083ee239d6b66109d068ea3b4dcc77ba06db7fe /sys/net | |
parent | 74ae735dc00571554d21c96495d3f4db8cf61232 (diff) |
Prefix fields of pfkey & routing PCBs, no functionnal change.
ok visa@, tb@
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/pfkeyv2.c | 31 | ||||
-rw-r--r-- | sys/net/rtsock.c | 52 |
2 files changed, 40 insertions, 43 deletions
diff --git a/sys/net/pfkeyv2.c b/sys/net/pfkeyv2.c index a68995e6411..ccb771ed3af 100644 --- a/sys/net/pfkeyv2.c +++ b/sys/net/pfkeyv2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkeyv2.c,v 1.181 2018/06/06 06:47:01 mpi Exp $ */ +/* $OpenBSD: pfkeyv2.c,v 1.182 2018/06/06 07:10:12 mpi Exp $ */ /* * @(#)COPYRIGHT 1.1 (NRL) 17 January 1995 @@ -133,7 +133,12 @@ struct sockaddr pfkey_addr = { 2, PF_KEY, }; struct domain pfkeydomain; struct keycb { - struct rawcb rcb; + struct rawcb kcb_rcb; +#define kcb_socket kcb_rcb.rcb_socket +#define kcb_faddr kcb_rcb.rcb_faddr +#define kcb_laddr kcb_rcb.rcb_laddr +#define kcb_proto kcb_rcb.rcb_proto + SRPL_ENTRY(keycb) kcb_list; struct refcnt refcnt; int flags; @@ -247,7 +252,6 @@ pfkey_init(void) int pfkeyv2_attach(struct socket *so, int proto) { - struct rawcb *rp; struct keycb *kp; int error; @@ -255,31 +259,24 @@ pfkeyv2_attach(struct socket *so, int proto) return EACCES; kp = malloc(sizeof(struct keycb), M_PCB, M_WAITOK | M_ZERO); - rp = &kp->rcb; - so->so_pcb = rp; + so->so_pcb = kp; refcnt_init(&kp->refcnt); error = soreserve(so, RAWSNDQ, RAWRCVQ); - if (error) { free(kp, M_PCB, sizeof(struct keycb)); return (error); } - rp->rcb_socket = so; - rp->rcb_proto.sp_family = so->so_proto->pr_domain->dom_family; - rp->rcb_proto.sp_protocol = proto; + kp->kcb_socket = so; + kp->kcb_proto.sp_family = so->so_proto->pr_domain->dom_family; + kp->kcb_proto.sp_protocol = proto; so->so_options |= SO_USELOOPBACK; soisconnected(so); - rp->rcb_faddr = &pfkey_addr; + kp->kcb_faddr = &pfkey_addr; kp->pid = curproc->p_p->ps_pid; - - /* - * XXX we should get this from the socket instead but - * XXX rawcb doesn't store the rdomain like inpcb does. - */ kp->rdomain = rtable_l2(curproc->p_p->ps_rtableid); rw_enter(&pfkey_cb.kcb_lk, RW_WRITE); @@ -373,7 +370,7 @@ ret: int pfkey_sendup(struct keycb *kp, struct mbuf *m0, int more) { - struct socket *so = kp->rcb.rcb_socket; + struct socket *so = kp->kcb_socket; struct mbuf *m; if (more) { @@ -473,7 +470,7 @@ pfkeyv2_sendmessage(void **headers, int mode, struct socket *so, */ SRPL_FOREACH(s, &sr, &pfkey_cb.kcb, kcb_list) { if ((s->flags & PFKEYV2_SOCKETFLAGS_PROMISC) && - (s->rcb.rcb_socket != so) && + (s->kcb_socket != so) && (s->rdomain == rdomain)) pfkey_sendup(s, packet, 1); } diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index d82e7057730..e73d306d294 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.266 2018/06/06 06:47:01 mpi Exp $ */ +/* $OpenBSD: rtsock.c,v 1.267 2018/06/06 07:10:12 mpi Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -135,8 +135,13 @@ int sysctl_ifnames(struct walkarg *); int sysctl_rtable_rtstat(void *, size_t *, void *); struct routecb { - struct rawcb rcb; - SRPL_ENTRY(routecb) rcb_list; + struct rawcb rop_rcb; +#define rop_socket rop_rcb.rcb_socket +#define rop_faddr rop_rcb.rcb_faddr +#define rop_laddr rop_rcb.rcb_laddr +#define rop_proto rop_rcb.rcb_proto + + SRPL_ENTRY(routecb) rop_list; struct refcnt refcnt; struct timeout timeout; unsigned int msgfilter; @@ -212,9 +217,8 @@ route_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, * empty so that we can clear the flag. */ if (((rop->flags & ROUTECB_FLAG_FLUSH) != 0) && - ((sbspace(rop->rcb.rcb_socket, - &rop->rcb.rcb_socket->so_rcv) == - rop->rcb.rcb_socket->so_rcv.sb_hiwat))) + ((sbspace(rop->rop_socket, &rop->rop_socket->so_rcv) == + rop->rop_socket->so_rcv.sb_hiwat))) rop->flags &= ~ROUTECB_FLAG_FLUSH; break; @@ -228,7 +232,6 @@ route_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, int route_attach(struct socket *so, int proto) { - struct rawcb *rp; struct routecb *rop; int error; @@ -238,7 +241,6 @@ route_attach(struct socket *so, int proto) * and works directly on the raw socket. */ rop = malloc(sizeof(struct routecb), M_PCB, M_WAITOK|M_ZERO); - rp = &rop->rcb; so->so_pcb = rop; /* Init the timeout structure */ timeout_set(&rop->timeout, rtm_senddesync, rop); @@ -253,19 +255,19 @@ route_attach(struct socket *so, int proto) return (error); } - rp->rcb_socket = so; - rp->rcb_proto.sp_family = so->so_proto->pr_domain->dom_family; - rp->rcb_proto.sp_protocol = proto; + rop->rop_socket = so; + rop->rop_proto.sp_family = so->so_proto->pr_domain->dom_family; + rop->rop_proto.sp_protocol = proto; rop->rtableid = curproc->p_p->ps_rtableid; soisconnected(so); so->so_options |= SO_USELOOPBACK; - rp->rcb_faddr = &route_src; + rop->rop_faddr = &route_src; rw_enter(&route_cb.rcb_lk, RW_WRITE); - SRPL_INSERT_HEAD_LOCKED(&route_cb.rcb_rc, &route_cb.rcb, rop, rcb_list); + SRPL_INSERT_HEAD_LOCKED(&route_cb.rcb_rc, &route_cb.rcb, rop, rop_list); route_cb.any_count++; rw_exit(&route_cb.rcb_lk); @@ -289,7 +291,7 @@ route_detach(struct socket *so) route_cb.any_count--; SRPL_REMOVE_LOCKED(&route_cb.rcb_rc, &route_cb.rcb, - rop, routecb, rcb_list); + rop, routecb, rop_list); rw_exit(&route_cb.rcb_lk); /* wait for all references to drop */ @@ -389,11 +391,11 @@ rtm_senddesync(void *data) */ desync_mbuf = rtm_msg1(RTM_DESYNC, NULL); if (desync_mbuf != NULL) { - struct socket *so = rop->rcb.rcb_socket; + struct socket *so = rop->rop_socket; if (sbappendaddr(so, &so->so_rcv, &route_src, desync_mbuf, NULL) != 0) { rop->flags &= ~ROUTECB_FLAG_DESYNC; - sorwakeup(rop->rcb.rcb_socket); + sorwakeup(rop->rop_socket); return; } m_freem(desync_mbuf); @@ -406,7 +408,6 @@ void route_input(struct mbuf *m0, struct socket *so, sa_family_t sa_family) { struct routecb *rop; - struct rawcb *rp; struct rt_msghdr *rtm; struct mbuf *m = m0; struct socket *last = NULL; @@ -420,14 +421,13 @@ route_input(struct mbuf *m0, struct socket *so, sa_family_t sa_family) return; } - SRPL_FOREACH(rop, &sr, &route_cb.rcb, rcb_list) { - rp = &rop->rcb; - if (!(rp->rcb_socket->so_state & SS_ISCONNECTED)) + SRPL_FOREACH(rop, &sr, &route_cb.rcb, rop_list) { + if (!(rop->rop_socket->so_state & SS_ISCONNECTED)) continue; - if (rp->rcb_socket->so_state & SS_CANTRCVMORE) + if (rop->rop_socket->so_state & SS_CANTRCVMORE) continue; /* Check to see if we don't want our own messages. */ - if (so == rp->rcb_socket && !(so->so_options & SO_USELOOPBACK)) + if (so == rop->rop_socket && !(so->so_options & SO_USELOOPBACK)) continue; /* @@ -435,9 +435,9 @@ route_input(struct mbuf *m0, struct socket *so, sa_family_t sa_family) * messages that match the address family. Address family * agnostic messages are always send. */ - if (rp->rcb_proto.sp_protocol != AF_UNSPEC && - sa_family != AF_UNSPEC && - rp->rcb_proto.sp_protocol != sa_family) + if (sa_family != AF_UNSPEC && + rop->rop_proto.sp_protocol != AF_UNSPEC && + rop->rop_proto.sp_protocol != sa_family) continue; /* filter messages that the process does not want */ @@ -483,7 +483,7 @@ route_input(struct mbuf *m0, struct socket *so, sa_family_t sa_family) } /* keep a reference for last */ refcnt_take(&rop->refcnt); - last = rop->rcb.rcb_socket; + last = rop->rop_socket; } SRPL_LEAVE(&sr); |