From 9c3b965e171241abfac6df0feeffb9d2ba07cd8f Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Mon, 27 Feb 2017 19:16:57 +0000 Subject: Retire the AF_MPLS protosw struct. Nothing is using it and the code was super basic anyway. Simplifies the code a lot also by calling the mpls sysctl no longer via the protosw but instead directly. OK mpi@ on a previous diff. Also tested by renato@ who actually found a bug which is now fixed. --- sys/kern/uipc_domain.c | 18 ++++++---------- sys/netmpls/mpls.h | 5 +---- sys/netmpls/mpls_input.c | 7 +----- sys/netmpls/mpls_proto.c | 29 +++++-------------------- sys/netmpls/mpls_raw.c | 55 +----------------------------------------------- sys/sys/sysctl.h | 3 ++- 6 files changed, 16 insertions(+), 101 deletions(-) diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c index 7dd629f5e6e..4a07e73fb9c 100644 --- a/sys/kern/uipc_domain.c +++ b/sys/kern/uipc_domain.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_domain.c,v 1.48 2016/12/20 21:15:36 mpi Exp $ */ +/* $OpenBSD: uipc_domain.c,v 1.49 2017/02/27 19:16:56 claudio Exp $ */ /* $NetBSD: uipc_domain.c,v 1.14 1996/02/09 19:00:44 christos Exp $ */ /* @@ -192,21 +192,15 @@ net_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, if (family == PF_PIPEX) return (pipex_sysctl(name + 1, namelen - 1, oldp, oldlenp, newp, newlen)); +#endif +#ifdef MPLS + if (family == PF_MPLS) + return (mpls_sysctl(name + 1, namelen - 1, oldp, oldlenp, + newp, newlen)); #endif dp = pffinddomain(family); if (dp == NULL) return (ENOPROTOOPT); -#ifdef MPLS - /* XXX WARNING: big fat ugly hack */ - /* stupid net.mpls is special as it does not have a protocol */ - if (family == PF_MPLS) { - NET_LOCK(s); - error = (dp->dom_protosw[0].pr_sysctl)(name + 1, namelen - 1, - oldp, oldlenp, newp, newlen); - NET_UNLOCK(s); - return (error); - } -#endif if (namelen < 3) return (EISDIR); /* overloaded */ diff --git a/sys/netmpls/mpls.h b/sys/netmpls/mpls.h index cbdfc375f29..81e8b524e7c 100644 --- a/sys/netmpls/mpls.h +++ b/sys/netmpls/mpls.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mpls.h,v 1.35 2015/12/02 08:47:00 claudio Exp $ */ +/* $OpenBSD: mpls.h,v 1.36 2017/02/27 19:16:56 claudio Exp $ */ /* * Copyright (C) 1999, 2000 and 2001 AYAME Project, WIDE Project. @@ -182,13 +182,10 @@ extern int mpls_mapttl_ip6; extern int mpls_inkloop; -void mpls_init(void); - struct mbuf *mpls_shim_pop(struct mbuf *); struct mbuf *mpls_shim_swap(struct mbuf *, struct rt_mpls *); struct mbuf *mpls_shim_push(struct mbuf *, struct rt_mpls *); -int mpls_sysctl(int *, u_int, void *, size_t *, void *, size_t); int mpls_output(struct ifnet *, struct mbuf *, struct sockaddr *, struct rtentry *); void mpls_input(struct mbuf *); diff --git a/sys/netmpls/mpls_input.c b/sys/netmpls/mpls_input.c index 23cb330ad0c..140c4a9d33d 100644 --- a/sys/netmpls/mpls_input.c +++ b/sys/netmpls/mpls_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpls_input.c,v 1.57 2016/08/22 15:37:23 mpi Exp $ */ +/* $OpenBSD: mpls_input.c,v 1.58 2017/02/27 19:16:56 claudio Exp $ */ /* * Copyright (c) 2008 Claudio Jeker @@ -52,11 +52,6 @@ int mpls_ip6_adjttl(struct mbuf *, u_int8_t); struct mbuf *mpls_do_error(struct mbuf *, int, int, int); -void -mpls_init(void) -{ -} - void mpls_input(struct mbuf *m) { diff --git a/sys/netmpls/mpls_proto.c b/sys/netmpls/mpls_proto.c index b35e2b065a1..078ad2b42fe 100644 --- a/sys/netmpls/mpls_proto.c +++ b/sys/netmpls/mpls_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpls_proto.c,v 1.14 2015/12/03 21:57:59 mpi Exp $ */ +/* $OpenBSD: mpls_proto.c,v 1.15 2017/02/27 19:16:56 claudio Exp $ */ /* * Copyright (C) 1999, 2000 and 2001 AYAME Project, WIDE Project. @@ -43,31 +43,12 @@ #include /* - * MPLS protocol family: + * MPLS address family: needed for the routing table */ -struct protosw mplssw[] = { -{ 0, &mplsdomain, 0, 0, - 0, 0, 0, 0, - 0, - mpls_init, 0, 0, 0, mpls_sysctl -}, -{ SOCK_DGRAM, &mplsdomain, 0, PR_ATOMIC|PR_ADDR, - 0, 0, 0, 0, - mpls_raw_usrreq, - 0, 0, 0, 0, mpls_sysctl, -}, -/* raw wildcard */ -{ SOCK_RAW, &mplsdomain, 0, PR_ATOMIC|PR_ADDR, - 0, 0, 0, 0, - mpls_raw_usrreq, - 0, 0, 0, 0, mpls_sysctl, -}, -}; - struct domain mplsdomain = { - AF_MPLS, "mpls", mpls_init, 0, 0, - mplssw, - &mplssw[nitems(mplssw)], + AF_MPLS, "mpls", NULL, 0, 0, + NULL, + 0, sizeof(struct sockaddr_mpls), offsetof(struct sockaddr_mpls, smpls_label), 32 }; diff --git a/sys/netmpls/mpls_raw.c b/sys/netmpls/mpls_raw.c index 1d740bff695..6d3a3fab105 100644 --- a/sys/netmpls/mpls_raw.c +++ b/sys/netmpls/mpls_raw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpls_raw.c,v 1.14 2016/11/15 13:44:03 mpi Exp $ */ +/* $OpenBSD: mpls_raw.c,v 1.15 2017/02/27 19:16:56 claudio Exp $ */ /* * Copyright (C) 1999, 2000 and 2001 AYAME Project, WIDE Project. @@ -45,12 +45,6 @@ #include -#define MPLS_RAW_SNDQ 8192 -#define MPLS_RAW_RCVQ 8192 - -u_long mpls_raw_sendspace = MPLS_RAW_SNDQ; -u_long mpls_raw_recvspace = MPLS_RAW_RCVQ; - int mpls_defttl = 255; int mpls_inkloop = MPLS_INKERNEL_LOOP_MAX; int mpls_push_expnull_ip = 0; @@ -60,53 +54,6 @@ int mpls_mapttl_ip6 = 0; int *mplsctl_vars[MPLSCTL_MAXID] = MPLSCTL_VARS; -int -mpls_raw_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, - struct mbuf *control, struct proc *p) -{ - int error = 0; - -#ifdef MPLS_DEBUG - printf("mpls_raw_usrreq: called! (reqid=%d).\n", req); -#endif /* MPLS_DEBUG */ - - if (req == PRU_CONTROL) - return (EOPNOTSUPP); - - switch (req) { - case PRU_ATTACH: - if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) { - error = soreserve(so, mpls_raw_sendspace, - mpls_raw_recvspace); - if (error) - break; - } - break; - - case PRU_DETACH: - case PRU_BIND: - case PRU_LISTEN: - case PRU_CONNECT: - case PRU_CONNECT2: - case PRU_DISCONNECT: - case PRU_SHUTDOWN: - case PRU_RCVD: - case PRU_SEND: - case PRU_SENSE: - case PRU_RCVOOB: - case PRU_SENDOOB: - case PRU_SOCKADDR: - case PRU_PEERADDR: - error = EOPNOTSUPP; - break; - - default: - panic("mpls_raw_usrreq"); - } - - return (error); -} - int mpls_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 51ea2510a7a..ca5213b373d 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.h,v 1.171 2017/01/21 05:42:03 guenther Exp $ */ +/* $OpenBSD: sysctl.h,v 1.172 2017/02/27 19:16:56 claudio Exp $ */ /* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */ /* @@ -976,6 +976,7 @@ extern void (*cpu_setperf)(int); int bpf_sysctl(int *, u_int, void *, size_t *, void *, size_t); int pflow_sysctl(int *, u_int, void *, size_t *, void *, size_t); int pipex_sysctl(int *, u_int, void *, size_t *, void *, size_t); +int mpls_sysctl(int *, u_int, void *, size_t *, void *, size_t); #else /* !_KERNEL */ -- cgit v1.2.3