summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/net
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-08-07 14:56:50 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-09-21 10:29:37 +0200
commitc37f9fba70085fedc8eede7559489d2321393005 (patch)
tree042455ebf1fa89a277a825f72e1ed805d0b4d296 /freebsd/sys/net
parentUpdate to FreeBSD head 2017-06-01 (diff)
downloadrtems-libbsd-c37f9fba70085fedc8eede7559489d2321393005.tar.bz2
Update to FreeBSD head 2017-08-01
Git mirror commit f5002f5e5f78cae9f0269d812dc0aedb0339312c. Update #3472.
Diffstat (limited to 'freebsd/sys/net')
-rw-r--r--freebsd/sys/net/bpf.c14
-rw-r--r--freebsd/sys/net/ethernet.h6
-rw-r--r--freebsd/sys/net/if_enc.c2
-rw-r--r--freebsd/sys/net/if_enc.h1
-rw-r--r--freebsd/sys/net/if_ethersubr.c7
-rw-r--r--freebsd/sys/net/if_lagg.c5
-rw-r--r--freebsd/sys/net/if_stf.c7
-rw-r--r--freebsd/sys/net/iflib.h3
-rw-r--r--freebsd/sys/net/route.c106
-rw-r--r--freebsd/sys/net/route.h2
10 files changed, 43 insertions, 110 deletions
diff --git a/freebsd/sys/net/bpf.c b/freebsd/sys/net/bpf.c
index d7a2abf7..b0ecb039 100644
--- a/freebsd/sys/net/bpf.c
+++ b/freebsd/sys/net/bpf.c
@@ -926,8 +926,6 @@ bpfopen(struct cdev *dev, int flags, int fmt, struct thread *td)
return (error);
}
#else /* __rtems__ */
- u_int size;
-
d = malloc(sizeof(*d), M_BPF, M_NOWAIT | M_ZERO);
if (d == NULL) {
return (d);
@@ -1360,7 +1358,7 @@ bpfioctl(struct bpf_d *d, u_long cmd, caddr_t addr, int flags,
#endif
case BIOCGETIF:
case BIOCGRTIMEOUT:
-#if defined(COMPAT_FREEBSD32) && !defined(__mips__)
+#if defined(COMPAT_FREEBSD32) && defined(__amd64__)
case BIOCGRTIMEOUT32:
#endif
case BIOCGSTATS:
@@ -1372,7 +1370,7 @@ bpfioctl(struct bpf_d *d, u_long cmd, caddr_t addr, int flags,
case FIONREAD:
case BIOCLOCK:
case BIOCSRTIMEOUT:
-#if defined(COMPAT_FREEBSD32) && !defined(__mips__)
+#if defined(COMPAT_FREEBSD32) && defined(__amd64__)
case BIOCSRTIMEOUT32:
#endif
case BIOCIMMEDIATE:
@@ -1596,7 +1594,7 @@ bpfioctl(struct bpf_d *d, u_long cmd, caddr_t addr, int flags,
* Set read timeout.
*/
case BIOCSRTIMEOUT:
-#if defined(COMPAT_FREEBSD32) && !defined(__mips__)
+#if defined(COMPAT_FREEBSD32) && defined(__amd64__)
case BIOCSRTIMEOUT32:
#endif
{
@@ -1627,12 +1625,12 @@ bpfioctl(struct bpf_d *d, u_long cmd, caddr_t addr, int flags,
* Get read timeout.
*/
case BIOCGRTIMEOUT:
-#if defined(COMPAT_FREEBSD32) && !defined(__mips__)
+#if defined(COMPAT_FREEBSD32) && defined(__amd64__)
case BIOCGRTIMEOUT32:
#endif
{
struct timeval *tv;
-#if defined(COMPAT_FREEBSD32) && !defined(__mips__)
+#if defined(COMPAT_FREEBSD32) && defined(__amd64__)
struct timeval32 *tv32;
struct timeval tv64;
@@ -1644,7 +1642,7 @@ bpfioctl(struct bpf_d *d, u_long cmd, caddr_t addr, int flags,
tv->tv_sec = d->bd_rtout / hz;
tv->tv_usec = (d->bd_rtout % hz) * tick;
-#if defined(COMPAT_FREEBSD32) && !defined(__mips__)
+#if defined(COMPAT_FREEBSD32) && defined(__amd64__)
if (cmd == BIOCGRTIMEOUT32) {
tv32 = (struct timeval32 *)addr;
tv32->tv_sec = tv->tv_sec;
diff --git a/freebsd/sys/net/ethernet.h b/freebsd/sys/net/ethernet.h
index bc5fa9cb..5cd1dc50 100644
--- a/freebsd/sys/net/ethernet.h
+++ b/freebsd/sys/net/ethernet.h
@@ -406,6 +406,12 @@ void ether_vlan_mtap(struct bpf_if *, struct mbuf *,
void *, u_int);
struct mbuf *ether_vlanencap(struct mbuf *, uint16_t);
+#ifdef _SYS_EVENTHANDLER_H_
+/* new ethernet interface attached event */
+typedef void (*ether_ifattach_event_handler_t)(void *, struct ifnet *);
+EVENTHANDLER_DECLARE(ether_ifattach_event, ether_ifattach_event_handler_t);
+#endif
+
#else /* _KERNEL */
#include <sys/cdefs.h>
diff --git a/freebsd/sys/net/if_enc.c b/freebsd/sys/net/if_enc.c
index 42b399d2..2a0b17d3 100644
--- a/freebsd/sys/net/if_enc.c
+++ b/freebsd/sys/net/if_enc.c
@@ -286,7 +286,7 @@ enc_hhook(int32_t hhook_type, int32_t hhook_id, void *udata, void *ctx_data,
/* Make a packet looks like it was received on enc(4) */
rcvif = (*ctx->mp)->m_pkthdr.rcvif;
(*ctx->mp)->m_pkthdr.rcvif = ifp;
- if (pfil_run_hooks(ph, ctx->mp, ifp, pdir, NULL) != 0 ||
+ if (pfil_run_hooks(ph, ctx->mp, ifp, pdir, ctx->inp) != 0 ||
*ctx->mp == NULL) {
*ctx->mp = NULL; /* consumed by filter */
return (EACCES);
diff --git a/freebsd/sys/net/if_enc.h b/freebsd/sys/net/if_enc.h
index 941ed12a..616c621f 100644
--- a/freebsd/sys/net/if_enc.h
+++ b/freebsd/sys/net/if_enc.h
@@ -33,6 +33,7 @@
struct ipsec_ctx_data {
struct mbuf **mp;
struct secasvar *sav;
+ struct inpcb *inp;
uint8_t af;
#define IPSEC_ENC_BEFORE 0x01
#define IPSEC_ENC_AFTER 0x02
diff --git a/freebsd/sys/net/if_ethersubr.c b/freebsd/sys/net/if_ethersubr.c
index c3c89d24..c0064fc6 100644
--- a/freebsd/sys/net/if_ethersubr.c
+++ b/freebsd/sys/net/if_ethersubr.c
@@ -40,6 +40,8 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/eventhandler.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
@@ -933,6 +935,11 @@ ether_ifattach(struct ifnet *ifp, const u_int8_t *lla)
if_printf(ifp, "Ethernet address: %6D\n", lla, ":");
uuid_ether_add(LLADDR(sdl));
+
+ /* Add necessary bits are setup; announce it now. */
+ EVENTHANDLER_INVOKE(ether_ifattach_event, ifp);
+ if (IS_DEFAULT_VNET(curvnet))
+ devctl_notify("ETHERNET", ifp->if_xname, "IFATTACH", NULL);
}
/*
diff --git a/freebsd/sys/net/if_lagg.c b/freebsd/sys/net/if_lagg.c
index 4d6e919e..ce696fb2 100644
--- a/freebsd/sys/net/if_lagg.c
+++ b/freebsd/sys/net/if_lagg.c
@@ -740,15 +740,16 @@ lagg_port_create(struct lagg_softc *sc, struct ifnet *ifp)
lagg_setmulti(lp);
+ LAGG_WUNLOCK(sc);
+
if ((error = lagg_proto_addport(sc, lp)) != 0) {
/* Remove the port, without calling pr_delport. */
+ LAGG_WLOCK(sc);
lagg_port_destroy(lp, 0);
LAGG_UNLOCK_ASSERT(sc);
return (error);
}
- LAGG_WUNLOCK(sc);
-
/* Update lagg capabilities */
lagg_capabilities(sc);
lagg_linkstate(sc);
diff --git a/freebsd/sys/net/if_stf.c b/freebsd/sys/net/if_stf.c
index 719dd1fa..b29c5f93 100644
--- a/freebsd/sys/net/if_stf.c
+++ b/freebsd/sys/net/if_stf.c
@@ -141,7 +141,6 @@ SYSCTL_INT(_net_link_stf, OID_AUTO, permit_rfc1918, CTLFLAG_RWTUN,
struct stf_softc {
struct ifnet *sc_ifp;
- struct mtx sc_ro_mtx;
u_int sc_fibnum;
const struct encaptab *encap_cookie;
};
@@ -149,10 +148,6 @@ struct stf_softc {
static const char stfname[] = "stf";
-/*
- * Note that mutable fields in the softc are not currently locked.
- * We do lock sc_ro in stf_output though.
- */
static MALLOC_DEFINE(M_STF, stfname, "6to4 Tunnel Interface");
static const int ip_stf_ttl = 40;
@@ -259,7 +254,6 @@ stf_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
ifp->if_dname = stfname;
ifp->if_dunit = IF_DUNIT_NONE;
- mtx_init(&(sc)->sc_ro_mtx, "stf ro", NULL, MTX_DEF);
sc->encap_cookie = encap_attach_func(AF_INET, IPPROTO_IPV6,
stf_encapcheck, &in_stf_protosw, sc);
if (sc->encap_cookie == NULL) {
@@ -286,7 +280,6 @@ stf_clone_destroy(struct if_clone *ifc, struct ifnet *ifp)
err = encap_detach(sc->encap_cookie);
KASSERT(err == 0, ("Unexpected error detaching encap_cookie"));
- mtx_destroy(&(sc)->sc_ro_mtx);
bpfdetach(ifp);
if_detach(ifp);
if_free(ifp);
diff --git a/freebsd/sys/net/iflib.h b/freebsd/sys/net/iflib.h
index 8bd20bfc..6ac75dbb 100644
--- a/freebsd/sys/net/iflib.h
+++ b/freebsd/sys/net/iflib.h
@@ -33,7 +33,6 @@
#include <sys/bus.h>
#include <sys/cpuset.h>
#include <machine/bus.h>
-#include <sys/bus_dma.h>
#include <sys/nv.h>
#include <sys/gtaskqueue.h>
@@ -201,8 +200,6 @@ typedef struct if_softc_ctx {
uint8_t isc_txd_size[8];
uint8_t isc_rxd_size[8];
- int isc_max_txqsets;
- int isc_max_rxqsets;
int isc_tx_tso_segments_max;
int isc_tx_tso_size_max;
int isc_tx_tso_segsize_max;
diff --git a/freebsd/sys/net/route.c b/freebsd/sys/net/route.c
index f7768737..a6a19cb0 100644
--- a/freebsd/sys/net/route.c
+++ b/freebsd/sys/net/route.c
@@ -61,7 +61,6 @@
#include <net/route.h>
#include <net/route_var.h>
#include <net/vnet.h>
-#include <net/flowtable.h>
#ifdef RADIX_MPATH
#include <net/radix_mpath.h>
@@ -486,18 +485,23 @@ rtalloc1_fib(struct sockaddr *dst, int report, u_long ignflags,
/*
* Look up the address in the table for that Address Family
*/
- RIB_RLOCK(rh);
+ if ((ignflags & RTF_RNH_LOCKED) == 0)
+ RIB_RLOCK(rh);
+#ifdef INVARIANTS
+ else
+ RIB_LOCK_ASSERT(rh);
+#endif
rn = rh->rnh_matchaddr(dst, &rh->head);
if (rn && ((rn->rn_flags & RNF_ROOT) == 0)) {
newrt = RNTORT(rn);
RT_LOCK(newrt);
RT_ADDREF(newrt);
- RIB_RUNLOCK(rh);
+ if ((ignflags & RTF_RNH_LOCKED) == 0)
+ RIB_RUNLOCK(rh);
return (newrt);
- } else
+ } else if ((ignflags & RTF_RNH_LOCKED) == 0)
RIB_RUNLOCK(rh);
-
/*
* Either we hit the root or could not find any match,
* which basically means: "cannot get there from here".
@@ -780,7 +784,9 @@ ifa_ifwithroute(int flags, const struct sockaddr *dst, struct sockaddr *gateway,
if (ifa == NULL)
ifa = ifa_ifwithnet(gateway, 0, fibnum);
if (ifa == NULL) {
- struct rtentry *rt = rtalloc1_fib(gateway, 0, 0, fibnum);
+ struct rtentry *rt;
+
+ rt = rtalloc1_fib(gateway, 0, flags, fibnum);
if (rt == NULL)
return (NULL);
/*
@@ -1529,79 +1535,12 @@ rt_mpath_unlink(struct rib_head *rnh, struct rt_addrinfo *info,
}
#endif
-#ifdef FLOWTABLE
-static struct rtentry *
-rt_flowtable_check_route(struct rib_head *rnh, struct rt_addrinfo *info)
-{
-#if defined(INET6) || defined(INET)
- struct radix_node *rn;
-#endif
- struct rtentry *rt0;
-
- rt0 = NULL;
- /* "flow-table" only supports IPv6 and IPv4 at the moment. */
- switch (dst->sa_family) {
-#ifdef INET6
- case AF_INET6:
-#endif
-#ifdef INET
- case AF_INET:
-#endif
-#if defined(INET6) || defined(INET)
- rn = rnh->rnh_matchaddr(dst, &rnh->head);
- if (rn && ((rn->rn_flags & RNF_ROOT) == 0)) {
- struct sockaddr *mask;
- u_char *m, *n;
- int len;
-
- /*
- * compare mask to see if the new route is
- * more specific than the existing one
- */
- rt0 = RNTORT(rn);
- RT_LOCK(rt0);
- RT_ADDREF(rt0);
- RT_UNLOCK(rt0);
- /*
- * A host route is already present, so
- * leave the flow-table entries as is.
- */
- if (rt0->rt_flags & RTF_HOST) {
- RTFREE(rt0);
- rt0 = NULL;
- } else if (!(flags & RTF_HOST) && netmask) {
- mask = rt_mask(rt0);
- len = mask->sa_len;
- m = (u_char *)mask;
- n = (u_char *)netmask;
- while (len-- > 0) {
- if (*n != *m)
- break;
- n++;
- m++;
- }
- if (len == 0 || (*n < *m)) {
- RTFREE(rt0);
- rt0 = NULL;
- }
- }
- }
-#endif/* INET6 || INET */
- }
-
- return (rt0);
-}
-#endif
-
int
rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt,
u_int fibnum)
{
int error = 0;
struct rtentry *rt, *rt_old;
-#ifdef FLOWTABLE
- struct rtentry *rt0;
-#endif
struct radix_node *rn;
struct rib_head *rnh;
struct ifaddr *ifa;
@@ -1735,10 +1674,6 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt,
}
#endif
-#ifdef FLOWTABLE
- rt0 = rt_flowtable_check_route(rnh, info);
-#endif /* FLOWTABLE */
-
/* XXX mtu manipulation will be done in rnh_addaddr -- itojun */
rn = rnh->rnh_addaddr(ndst, netmask, &rnh->head, rt->rt_nodes);
@@ -1773,18 +1708,8 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt,
ifa_free(rt->rt_ifa);
R_Free(rt_key(rt));
uma_zfree(V_rtzone, rt);
-#ifdef FLOWTABLE
- if (rt0 != NULL)
- RTFREE(rt0);
-#endif
return (EEXIST);
}
-#ifdef FLOWTABLE
- else if (rt0 != NULL) {
- flowtable_route_flush(dst->sa_family, rt0);
- RTFREE(rt0);
- }
-#endif
if (rt_old != NULL) {
rt_notifydelete(rt_old, info);
@@ -1870,8 +1795,13 @@ rtrequest1_fib_change(struct rib_head *rnh, struct rt_addrinfo *info,
info->rti_info[RTAX_IFP] != NULL ||
(info->rti_info[RTAX_IFA] != NULL &&
!sa_equal(info->rti_info[RTAX_IFA], rt->rt_ifa->ifa_addr))) {
-
+ /*
+ * XXX: Temporarily set RTF_RNH_LOCKED flag in the rti_flags
+ * to avoid rlock in the ifa_ifwithroute().
+ */
+ info->rti_flags |= RTF_RNH_LOCKED;
error = rt_getifa_fib(info, fibnum);
+ info->rti_flags &= ~RTF_RNH_LOCKED;
if (info->rti_ifa != NULL)
free_ifa = 1;
diff --git a/freebsd/sys/net/route.h b/freebsd/sys/net/route.h
index d4bc4056..444559b5 100644
--- a/freebsd/sys/net/route.h
+++ b/freebsd/sys/net/route.h
@@ -189,7 +189,7 @@ struct rtentry {
/* 0x8000000 and up unassigned */
#define RTF_STICKY 0x10000000 /* always route dst->src */
-#define RTF_RNH_LOCKED 0x40000000 /* unused */
+#define RTF_RNH_LOCKED 0x40000000 /* radix node head is locked */
#define RTF_GWFLAG_COMPAT 0x80000000 /* a compatibility bit for interacting
with existing routing apps */