diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-06-11 09:05:06 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-06-11 09:05:06 +0000 |
commit | 6abc9a3f22158b4635f41c5f86c6898bab4a85c2 (patch) | |
tree | 378cab78f72c9cc5ddadca979ba83384f7b15922 /sys | |
parent | 45a77eef8ce3ef3f5407613b411ff313d09d9af1 (diff) |
Rename routing & pfkey tables for coherency with other PCB tables.
ok claudio@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/pfkeyv2.c | 82 | ||||
-rw-r--r-- | sys/net/rtsock.c | 92 |
2 files changed, 87 insertions, 87 deletions
diff --git a/sys/net/pfkeyv2.c b/sys/net/pfkeyv2.c index 5ace5c77fd5..f4501324c1c 100644 --- a/sys/net/pfkeyv2.c +++ b/sys/net/pfkeyv2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkeyv2.c,v 1.183 2018/06/06 07:12:51 mpi Exp $ */ +/* $OpenBSD: pfkeyv2.c,v 1.184 2018/06/11 09:05:05 mpi Exp $ */ /* * @(#)COPYRIGHT 1.1 (NRL) 17 January 1995 @@ -132,21 +132,21 @@ extern struct radix_node_head **spd_tables; struct sockaddr pfkey_addr = { 2, PF_KEY, }; struct domain pfkeydomain; -struct keycb { - 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 +struct pkpcb { + struct rawcb pkp_rcb; +#define kcb_socket pkp_rcb.rcb_socket +#define kcb_faddr pkp_rcb.rcb_faddr +#define kcb_laddr pkp_rcb.rcb_laddr +#define kcb_proto pkp_rcb.rcb_proto - SRPL_ENTRY(keycb) kcb_list; + SRPL_ENTRY(pkpcb) kcb_list; struct refcnt kcb_refcnt; int kcb_flags; uint32_t kcb_pid; uint32_t kcb_registration; /* Inc. if SATYPE_MAX > 31 */ unsigned int kcb_rdomain; }; -#define sotokeycb(so) ((struct keycb *)(so)->so_pcb) +#define sotokeycb(so) ((struct pkpcb *)(so)->so_pcb) struct dump_state { @@ -154,13 +154,13 @@ struct dump_state { struct socket *socket; }; -struct pfkey_cb { - SRPL_HEAD(, keycb) kcb; - struct srpl_rc kcb_rc; - struct rwlock kcb_lk; +struct pkptable { + SRPL_HEAD(, pkpcb) pkp_list; + struct srpl_rc pkp_rc; + struct rwlock pkp_lk; }; -struct pfkey_cb pfkey_cb; +struct pkptable pkptable; struct mutex pfkeyv2_mtx = MUTEX_INITIALIZER(IPL_NONE); static uint32_t pfkeyv2_seq = 1; static int nregistered = 0; @@ -174,7 +174,7 @@ int pfkeyv2_usrreq(struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *); int pfkeyv2_output(struct mbuf *, struct socket *, struct sockaddr *, struct mbuf *); -int pfkey_sendup(struct keycb *, struct mbuf *, int); +int pfkey_sendup(struct pkpcb *, struct mbuf *, int); int pfkeyv2_sa_flush(struct tdb *, void *, int); int pfkeyv2_policy_flush(struct ipsec_policy *, void *, unsigned int); int pfkeyv2_sysctl_policydumper(struct ipsec_policy *, void *, unsigned int); @@ -223,7 +223,7 @@ struct domain pfkeydomain = { void keycb_ref(void *null, void *v) { - struct keycb *kp = v; + struct pkpcb *kp = v; refcnt_take(&kp->kcb_refcnt); } @@ -231,7 +231,7 @@ keycb_ref(void *null, void *v) void keycb_unref(void *null, void *v) { - struct keycb *kp = v; + struct pkpcb *kp = v; refcnt_rele_wake(&kp->kcb_refcnt); } @@ -240,9 +240,9 @@ void pfkey_init(void) { rn_init(sizeof(struct sockaddr_encap)); - srpl_rc_init(&pfkey_cb.kcb_rc, keycb_ref, keycb_unref, NULL); - rw_init(&pfkey_cb.kcb_lk, "pfkey"); - SRPL_INIT(&pfkey_cb.kcb); + srpl_rc_init(&pkptable.pkp_rc, keycb_ref, keycb_unref, NULL); + rw_init(&pkptable.pkp_lk, "pfkey"); + SRPL_INIT(&pkptable.pkp_list); } @@ -252,19 +252,19 @@ pfkey_init(void) int pfkeyv2_attach(struct socket *so, int proto) { - struct keycb *kp; + struct pkpcb *kp; int error; if ((so->so_state & SS_PRIV) == 0) return EACCES; - kp = malloc(sizeof(struct keycb), M_PCB, M_WAITOK | M_ZERO); + kp = malloc(sizeof(struct pkpcb), M_PCB, M_WAITOK | M_ZERO); so->so_pcb = kp; refcnt_init(&kp->kcb_refcnt); error = soreserve(so, RAWSNDQ, RAWRCVQ); if (error) { - free(kp, M_PCB, sizeof(struct keycb)); + free(kp, M_PCB, sizeof(struct pkpcb)); return (error); } @@ -279,9 +279,9 @@ pfkeyv2_attach(struct socket *so, int proto) kp->kcb_pid = curproc->p_p->ps_pid; kp->kcb_rdomain = rtable_l2(curproc->p_p->ps_rtableid); - rw_enter(&pfkey_cb.kcb_lk, RW_WRITE); - SRPL_INSERT_HEAD_LOCKED(&pfkey_cb.kcb_rc, &pfkey_cb.kcb, kp, kcb_list); - rw_exit(&pfkey_cb.kcb_lk); + rw_enter(&pkptable.pkp_lk, RW_WRITE); + SRPL_INSERT_HEAD_LOCKED(&pkptable.pkp_rc, &pkptable.pkp_list, kp, kcb_list); + rw_exit(&pkptable.pkp_lk); return (0); } @@ -292,7 +292,7 @@ pfkeyv2_attach(struct socket *so, int proto) int pfkeyv2_detach(struct socket *so) { - struct keycb *kp; + struct pkpcb *kp; soassertlocked(so); @@ -311,17 +311,17 @@ pfkeyv2_detach(struct socket *so) mtx_leave(&pfkeyv2_mtx); } - rw_enter(&pfkey_cb.kcb_lk, RW_WRITE); - SRPL_REMOVE_LOCKED(&pfkey_cb.kcb_rc, &pfkey_cb.kcb, - kp, keycb, kcb_list); - rw_exit(&pfkey_cb.kcb_lk); + rw_enter(&pkptable.pkp_lk, RW_WRITE); + SRPL_REMOVE_LOCKED(&pkptable.pkp_rc, &pkptable.pkp_list, kp, pkpcb, + kcb_list); + rw_exit(&pkptable.pkp_lk); /* wait for all references to drop */ refcnt_finalize(&kp->kcb_refcnt, "pfkeyrefs"); so->so_pcb = NULL; KASSERT((so->so_state & SS_NOFDREF) == 0); - free(kp, M_PCB, sizeof(struct keycb)); + free(kp, M_PCB, sizeof(struct pkpcb)); return (0); } @@ -368,7 +368,7 @@ ret: } int -pfkey_sendup(struct keycb *kp, struct mbuf *m0, int more) +pfkey_sendup(struct pkpcb *kp, struct mbuf *m0, int more) { struct socket *so = kp->kcb_socket; struct mbuf *m; @@ -403,7 +403,7 @@ pfkeyv2_sendmessage(void **headers, int mode, struct socket *so, int i, j, rval; void *p, *buffer = NULL; struct mbuf *packet; - struct keycb *s; + struct pkpcb *s; struct sadb_msg *smsg; struct srp_ref sr; @@ -468,7 +468,7 @@ pfkeyv2_sendmessage(void **headers, int mode, struct socket *so, * Search for promiscuous listeners, skipping the * original destination. */ - SRPL_FOREACH(s, &sr, &pfkey_cb.kcb, kcb_list) { + SRPL_FOREACH(s, &sr, &pkptable.pkp_list, kcb_list) { if ((s->kcb_flags & PFKEYV2_SOCKETFLAGS_PROMISC) && (s->kcb_socket != so) && (s->kcb_rdomain == rdomain)) @@ -483,7 +483,7 @@ pfkeyv2_sendmessage(void **headers, int mode, struct socket *so, * Send the message to all registered sockets that match * the specified satype (e.g., all IPSEC-ESP negotiators) */ - SRPL_FOREACH(s, &sr, &pfkey_cb.kcb, kcb_list) { + SRPL_FOREACH(s, &sr, &pkptable.pkp_list, kcb_list) { if ((s->kcb_flags & PFKEYV2_SOCKETFLAGS_REGISTERED) && (s->kcb_rdomain == rdomain)) { if (!satype) /* Just send to everyone registered */ @@ -514,7 +514,7 @@ pfkeyv2_sendmessage(void **headers, int mode, struct socket *so, goto ret; /* Send to all registered promiscuous listeners */ - SRPL_FOREACH(s, &sr, &pfkey_cb.kcb, kcb_list) { + SRPL_FOREACH(s, &sr, &pkptable.pkp_list, kcb_list) { if ((s->kcb_flags & PFKEYV2_SOCKETFLAGS_PROMISC) && !(s->kcb_flags & PFKEYV2_SOCKETFLAGS_REGISTERED) && (s->kcb_rdomain == rdomain)) @@ -526,7 +526,7 @@ pfkeyv2_sendmessage(void **headers, int mode, struct socket *so, case PFKEYV2_SENDMESSAGE_BROADCAST: /* Send message to all sockets */ - SRPL_FOREACH(s, &sr, &pfkey_cb.kcb, kcb_list) { + SRPL_FOREACH(s, &sr, &pkptable.pkp_list, kcb_list) { if (s->kcb_rdomain == rdomain) pfkey_sendup(s, packet, 1); } @@ -997,7 +997,7 @@ pfkeyv2_send(struct socket *so, void *message, int len) struct ipsec_acquire *ipa; struct radix_node_head *rnh; struct radix_node *rn = NULL; - struct keycb *kp, *bkp; + struct pkpcb *kp, *bkp; void *freeme = NULL, *bckptr = NULL; void *headers[SADB_EXT_MAX + 1]; union sockaddr_union *sunionp; @@ -1055,7 +1055,7 @@ pfkeyv2_send(struct socket *so, void *message, int len) goto ret; /* Send to all promiscuous listeners */ - SRPL_FOREACH(bkp, &sr, &pfkey_cb.kcb, kcb_list) { + SRPL_FOREACH(bkp, &sr, &pkptable.pkp_list, kcb_list) { if ((bkp->kcb_flags & PFKEYV2_SOCKETFLAGS_PROMISC) && (bkp->kcb_rdomain == rdomain)) pfkey_sendup(bkp, packet, 1); @@ -1830,7 +1830,7 @@ pfkeyv2_send(struct socket *so, void *message, int len) if ((rval = pfdatatopacket(message, len, &packet)) != 0) goto ret; - SRPL_FOREACH(bkp, &sr, &pfkey_cb.kcb, kcb_list) { + SRPL_FOREACH(bkp, &sr, &pkptable.pkp_list, kcb_list) { if ((bkp != kp) && (bkp->kcb_rdomain == rdomain) && (!smsg->sadb_msg_seq || diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 98f49e6f1c2..354360488b8 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.269 2018/06/11 08:48:54 mpi Exp $ */ +/* $OpenBSD: rtsock.c,v 1.270 2018/06/11 09:05:05 mpi Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -135,14 +135,14 @@ int sysctl_iflist(int, struct walkarg *); int sysctl_ifnames(struct walkarg *); int sysctl_rtable_rtstat(void *, size_t *, void *); -struct routecb { +struct rtpcb { 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; + SRPL_ENTRY(rtpcb) rop_list; struct refcnt rop_refcnt; struct timeout rop_timeout; unsigned int rop_msgfilter; @@ -150,16 +150,16 @@ struct routecb { u_int rop_rtableid; u_char rop_priority; }; -#define sotoroutecb(so) ((struct routecb *)(so)->so_pcb) +#define sotortpcb(so) ((struct rtpcb *)(so)->so_pcb) -struct route_cb { - SRPL_HEAD(, routecb) rcb; - struct srpl_rc rcb_rc; - struct rwlock rcb_lk; - unsigned int any_count; +struct rtptable { + SRPL_HEAD(, rtpcb) rtp_list; + struct srpl_rc rtp_rc; + struct rwlock rtp_lk; + unsigned int rtp_count; }; -struct route_cb route_cb; +struct rtptable rtptable; /* * These flags and timeout are used for indicating to userland (via a @@ -175,15 +175,15 @@ struct route_cb route_cb; void route_prinit(void) { - srpl_rc_init(&route_cb.rcb_rc, rcb_ref, rcb_unref, NULL); - rw_init(&route_cb.rcb_lk, "rtsock"); - SRPL_INIT(&route_cb.rcb); + srpl_rc_init(&rtptable.rtp_rc, rcb_ref, rcb_unref, NULL); + rw_init(&rtptable.rtp_lk, "rtsock"); + SRPL_INIT(&rtptable.rtp_list); } void rcb_ref(void *null, void *v) { - struct routecb *rop = v; + struct rtpcb *rop = v; refcnt_take(&rop->rop_refcnt); } @@ -191,7 +191,7 @@ rcb_ref(void *null, void *v) void rcb_unref(void *null, void *v) { - struct routecb *rop = v; + struct rtpcb *rop = v; refcnt_rele_wake(&rop->rop_refcnt); } @@ -200,12 +200,12 @@ int route_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, struct mbuf *control, struct proc *p) { - struct routecb *rop; + struct rtpcb *rop; int error = 0; soassertlocked(so); - rop = sotoroutecb(so); + rop = sotortpcb(so); if (rop == NULL) { m_freem(m); return (EINVAL); @@ -233,15 +233,15 @@ route_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, int route_attach(struct socket *so, int proto) { - struct routecb *rop; + struct rtpcb *rop; int error; /* - * use the rawcb but allocate a routecb, this + * use the rawcb but allocate a rtpcb, this * code does not care about the additional fields * and works directly on the raw socket. */ - rop = malloc(sizeof(struct routecb), M_PCB, M_WAITOK|M_ZERO); + rop = malloc(sizeof(struct rtpcb), M_PCB, M_WAITOK|M_ZERO); so->so_pcb = rop; /* Init the timeout structure */ timeout_set(&rop->rop_timeout, rtm_senddesync_timer, so); @@ -252,7 +252,7 @@ route_attach(struct socket *so, int proto) else error = soreserve(so, RAWSNDQ, RAWRCVQ); if (error) { - free(rop, M_PCB, sizeof(struct routecb)); + free(rop, M_PCB, sizeof(struct rtpcb)); return (error); } @@ -267,10 +267,10 @@ route_attach(struct socket *so, int proto) 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, rop_list); - route_cb.any_count++; - rw_exit(&route_cb.rcb_lk); + rw_enter(&rtptable.rtp_lk, RW_WRITE); + SRPL_INSERT_HEAD_LOCKED(&rtptable.rtp_rc, &rtptable.rtp_list, rop, rop_list); + rtptable.rtp_count++; + rw_exit(&rtptable.rtp_lk); return (0); } @@ -278,29 +278,29 @@ route_attach(struct socket *so, int proto) int route_detach(struct socket *so) { - struct routecb *rop; + struct rtpcb *rop; soassertlocked(so); - rop = sotoroutecb(so); + rop = sotortpcb(so); if (rop == NULL) return (EINVAL); - rw_enter(&route_cb.rcb_lk, RW_WRITE); + rw_enter(&rtptable.rtp_lk, RW_WRITE); timeout_del(&rop->rop_timeout); - route_cb.any_count--; + rtptable.rtp_count--; - SRPL_REMOVE_LOCKED(&route_cb.rcb_rc, &route_cb.rcb, - rop, routecb, rop_list); - rw_exit(&route_cb.rcb_lk); + SRPL_REMOVE_LOCKED(&rtptable.rtp_rc, &rtptable.rtp_list, rop, rtpcb, + rop_list); + rw_exit(&rtptable.rtp_lk); /* wait for all references to drop */ refcnt_finalize(&rop->rop_refcnt, "rtsockrefs"); so->so_pcb = NULL; KASSERT((so->so_state & SS_NOFDREF) == 0); - free(rop, M_PCB, sizeof(struct routecb)); + free(rop, M_PCB, sizeof(struct rtpcb)); return (0); } @@ -309,7 +309,7 @@ int route_ctloutput(int op, struct socket *so, int level, int optname, struct mbuf *m) { - struct routecb *rop = sotoroutecb(so); + struct rtpcb *rop = sotortpcb(so); int error = 0; unsigned int tid, prio; @@ -388,7 +388,7 @@ rtm_senddesync_timer(void *xso) void rtm_senddesync(struct socket *so) { - struct routecb *rop = sotoroutecb(so); + struct rtpcb *rop = sotortpcb(so); struct mbuf *desync_mbuf; soassertlocked(so); @@ -419,7 +419,7 @@ void route_input(struct mbuf *m0, struct socket *so0, sa_family_t sa_family) { struct socket *so; - struct routecb *rop; + struct rtpcb *rop; struct rt_msghdr *rtm; struct mbuf *m = m0; struct socket *last = NULL; @@ -432,7 +432,7 @@ route_input(struct mbuf *m0, struct socket *so0, sa_family_t sa_family) return; } - SRPL_FOREACH(rop, &sr, &route_cb.rcb, rop_list) { + SRPL_FOREACH(rop, &sr, &rtptable.rtp_list, rop_list) { /* * If route socket is bound to an address family only send * messages that match the address family. Address family @@ -502,7 +502,7 @@ next: s = solock(last); rtm_sendup(last, m, 1); sounlock(last, s); - refcnt_rele_wake(&sotoroutecb(last)->rop_refcnt); + refcnt_rele_wake(&sotortpcb(last)->rop_refcnt); } /* keep a reference for last */ refcnt_take(&rop->rop_refcnt); @@ -514,7 +514,7 @@ next: s = solock(last); rtm_sendup(last, m, 0); sounlock(last, s); - refcnt_rele_wake(&sotoroutecb(last)->rop_refcnt); + refcnt_rele_wake(&sotortpcb(last)->rop_refcnt); } else m_freem(m); } @@ -522,7 +522,7 @@ next: int rtm_sendup(struct socket *so, struct mbuf *m0, int more) { - struct routecb *rop = sotoroutecb(so); + struct rtpcb *rop = sotortpcb(so); struct mbuf *m; soassertlocked(so); @@ -775,7 +775,7 @@ route_output(struct mbuf *m, struct socket *so, struct sockaddr *dstaddr, * Check to see if we don't want our own messages. */ if (!(so->so_options & SO_USELOOPBACK)) { - if (route_cb.any_count <= 1) { + if (rtptable.rtp_count <= 1) { /* no other listener and no loopback of messages */ fail: free(rtm, M_RTABLE, len); @@ -1485,7 +1485,7 @@ rtm_miss(int type, struct rt_addrinfo *rtinfo, int flags, uint8_t prio, struct mbuf *m; struct sockaddr *sa = rtinfo->rti_info[RTAX_DST]; - if (route_cb.any_count == 0) + if (rtptable.rtp_count == 0) return; m = rtm_msg1(type, rtinfo); if (m == NULL) @@ -1510,7 +1510,7 @@ rtm_ifchg(struct ifnet *ifp) struct if_msghdr *ifm; struct mbuf *m; - if (route_cb.any_count == 0) + if (rtptable.rtp_count == 0) return; m = rtm_msg1(RTM_IFINFO, NULL); if (m == NULL) @@ -1541,7 +1541,7 @@ rtm_addr(int cmd, struct ifaddr *ifa) struct rt_addrinfo info; struct ifa_msghdr *ifam; - if (route_cb.any_count == 0) + if (rtptable.rtp_count == 0) return; memset(&info, 0, sizeof(info)); @@ -1572,7 +1572,7 @@ rtm_ifannounce(struct ifnet *ifp, int what) struct if_announcemsghdr *ifan; struct mbuf *m; - if (route_cb.any_count == 0) + if (rtptable.rtp_count == 0) return; m = rtm_msg1(RTM_IFANNOUNCE, NULL); if (m == NULL) @@ -1597,7 +1597,7 @@ rtm_bfd(struct bfd_config *bfd) struct mbuf *m; struct rt_addrinfo info; - if (route_cb.any_count == 0) + if (rtptable.rtp_count == 0) return; memset(&info, 0, sizeof(info)); info.rti_info[RTAX_DST] = rt_key(bfd->bc_rt); |