summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/net
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-12-09 14:19:03 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-01-10 09:53:34 +0100
commit75b706fde4cbf82bcd41a1cec319778aa0f8eb2d (patch)
treeea39a351a1f6337b5a5dd6036314693adef5ffe6 /freebsd/sys/net
parentVMSTAT(8): Port to RTEMS (diff)
downloadrtems-libbsd-75b706fde4cbf82bcd41a1cec319778aa0f8eb2d.tar.bz2
Update to FreeBSD head 2016-12-10
Git mirror commit 80c55f08a05ab3b26a73b226ccb56adc3122a55c.
Diffstat (limited to 'freebsd/sys/net')
-rw-r--r--freebsd/sys/net/altq/altq_subr.c2
-rw-r--r--freebsd/sys/net/bpf_filter.c25
-rw-r--r--freebsd/sys/net/ethernet.h2
-rw-r--r--freebsd/sys/net/if.c2
-rw-r--r--freebsd/sys/net/if_arcsubr.c2
-rw-r--r--freebsd/sys/net/if_bridge.c88
-rw-r--r--freebsd/sys/net/if_fddisubr.c2
-rw-r--r--freebsd/sys/net/if_iso88025subr.c2
-rw-r--r--freebsd/sys/net/if_llatbl.c35
-rw-r--r--freebsd/sys/net/if_llatbl.h8
-rw-r--r--freebsd/sys/net/if_loop.c5
-rw-r--r--freebsd/sys/net/if_var.h10
-rw-r--r--freebsd/sys/net/pfkeyv2.h11
-rw-r--r--freebsd/sys/net/raw_usrreq.c2
-rw-r--r--freebsd/sys/net/route.c9
-rw-r--r--freebsd/sys/net/route_var.h2
-rw-r--r--freebsd/sys/net/rtsock.c42
17 files changed, 151 insertions, 98 deletions
diff --git a/freebsd/sys/net/altq/altq_subr.c b/freebsd/sys/net/altq/altq_subr.c
index 66ff441d..a9a68b37 100644
--- a/freebsd/sys/net/altq/altq_subr.c
+++ b/freebsd/sys/net/altq/altq_subr.c
@@ -437,7 +437,7 @@ tbr_timeout(arg)
VNET_FOREACH(vnet_iter) {
CURVNET_SET(vnet_iter);
for (ifp = TAILQ_FIRST(&V_ifnet); ifp;
- ifp = TAILQ_NEXT(ifp, if_list)) {
+ ifp = TAILQ_NEXT(ifp, if_link)) {
/* read from if_snd unlocked */
if (!TBR_IS_ENABLED(&ifp->if_snd))
continue;
diff --git a/freebsd/sys/net/bpf_filter.c b/freebsd/sys/net/bpf_filter.c
index 941fa290..ecfb3d14 100644
--- a/freebsd/sys/net/bpf_filter.c
+++ b/freebsd/sys/net/bpf_filter.c
@@ -436,6 +436,12 @@ bpf_filter(const struct bpf_insn *pc, u_char *p, u_int wirelen, u_int buflen)
A /= X;
continue;
+ case BPF_ALU|BPF_MOD|BPF_X:
+ if (X == 0)
+ return (0);
+ A %= X;
+ continue;
+
case BPF_ALU|BPF_AND|BPF_X:
A &= X;
continue;
@@ -444,6 +450,10 @@ bpf_filter(const struct bpf_insn *pc, u_char *p, u_int wirelen, u_int buflen)
A |= X;
continue;
+ case BPF_ALU|BPF_XOR|BPF_X:
+ A ^= X;
+ continue;
+
case BPF_ALU|BPF_LSH|BPF_X:
A <<= X;
continue;
@@ -468,6 +478,10 @@ bpf_filter(const struct bpf_insn *pc, u_char *p, u_int wirelen, u_int buflen)
A /= pc->k;
continue;
+ case BPF_ALU|BPF_MOD|BPF_K:
+ A %= pc->k;
+ continue;
+
case BPF_ALU|BPF_AND|BPF_K:
A &= pc->k;
continue;
@@ -476,6 +490,10 @@ bpf_filter(const struct bpf_insn *pc, u_char *p, u_int wirelen, u_int buflen)
A |= pc->k;
continue;
+ case BPF_ALU|BPF_XOR|BPF_K:
+ A ^= pc->k;
+ continue;
+
case BPF_ALU|BPF_LSH|BPF_K:
A <<= pc->k;
continue;
@@ -510,8 +528,8 @@ static const u_short bpf_code_map[] = {
0x1013, /* 0x60-0x6f: 1100100000001000 */
0x1010, /* 0x70-0x7f: 0000100000001000 */
0x0093, /* 0x80-0x8f: 1100100100000000 */
- 0x0000, /* 0x90-0x9f: 0000000000000000 */
- 0x0000, /* 0xa0-0xaf: 0000000000000000 */
+ 0x1010, /* 0x90-0x9f: 0000100000001000 */
+ 0x1010, /* 0xa0-0xaf: 0000100000001000 */
0x0002, /* 0xb0-0xbf: 0100000000000000 */
0x0000, /* 0xc0-0xcf: 0000000000000000 */
0x0000, /* 0xd0-0xdf: 0000000000000000 */
@@ -579,7 +597,8 @@ bpf_validate(const struct bpf_insn *f, int len)
/*
* Check for constant division by 0.
*/
- if (p->code == (BPF_ALU|BPF_DIV|BPF_K) && p->k == 0)
+ if ((p->code == (BPF_ALU|BPF_DIV|BPF_K) ||
+ p->code == (BPF_ALU|BPF_MOD|BPF_K)) && p->k == 0)
return (0);
}
return (BPF_CLASS(f[len - 1].code) == BPF_RET);
diff --git a/freebsd/sys/net/ethernet.h b/freebsd/sys/net/ethernet.h
index bc5fa9cb..5ec9d20e 100644
--- a/freebsd/sys/net/ethernet.h
+++ b/freebsd/sys/net/ethernet.h
@@ -92,7 +92,7 @@ struct ether_vlan_header {
#define EVL_PRIOFTAG(tag) (((tag) >> 13) & 7)
#define EVL_CFIOFTAG(tag) (((tag) >> 12) & 1)
#define EVL_MAKETAG(vlid, pri, cfi) \
- ((((((pri) & 7) << 1) | ((cfi) & 1)) << 12) | ((vlid) & EVL_VLID_MASK))
+ ((((((pri) & 7) << 13) | ((cfi) & 1)) << 12) | ((vlid) & EVL_VLID_MASK))
/*
* NOTE: 0x0000-0x05DC (0..1500) are generally IEEE 802.3 length fields.
diff --git a/freebsd/sys/net/if.c b/freebsd/sys/net/if.c
index 8bfa9e21..e1c525bd 100644
--- a/freebsd/sys/net/if.c
+++ b/freebsd/sys/net/if.c
@@ -2208,7 +2208,7 @@ do_link_state_change(void *arg, int pending)
if (log_link_state_change)
log(LOG_NOTICE, "%s: link state changed to %s\n", ifp->if_xname,
(link_state == LINK_STATE_UP) ? "UP" : "DOWN" );
- EVENTHANDLER_INVOKE(ifnet_link_event, ifp, ifp->if_link_state);
+ EVENTHANDLER_INVOKE(ifnet_link_event, ifp, link_state);
CURVNET_RESTORE();
}
diff --git a/freebsd/sys/net/if_arcsubr.c b/freebsd/sys/net/if_arcsubr.c
index 1954e262..042f3e84 100644
--- a/freebsd/sys/net/if_arcsubr.c
+++ b/freebsd/sys/net/if_arcsubr.c
@@ -227,7 +227,7 @@ arc_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
if ((ifp->if_flags & IFF_SIMPLEX) && (loop_copy != -1)) {
if ((m->m_flags & M_BCAST) || (loop_copy > 0)) {
- struct mbuf *n = m_copy(m, 0, (int)M_COPYALL);
+ struct mbuf *n = m_copym(m, 0, M_COPYALL, M_NOWAIT);
(void) if_simloop(ifp, n, dst->sa_family, ARC_HDRLEN);
} else if (ah->arc_dhost == ah->arc_shost) {
diff --git a/freebsd/sys/net/if_bridge.c b/freebsd/sys/net/if_bridge.c
index 77b376b9..fc0dbffd 100644
--- a/freebsd/sys/net/if_bridge.c
+++ b/freebsd/sys/net/if_bridge.c
@@ -335,7 +335,7 @@ static int bridge_ip_checkbasic(struct mbuf **mp);
#ifdef INET6
static int bridge_ip6_checkbasic(struct mbuf **mp);
#endif /* INET6 */
-static int bridge_fragment(struct ifnet *, struct mbuf *,
+static int bridge_fragment(struct ifnet *, struct mbuf **mp,
struct ether_header *, int, struct llc *);
static void bridge_linkstate(struct ifnet *ifp);
static void bridge_linkcheck(struct bridge_softc *sc);
@@ -410,7 +410,7 @@ SYSCTL_INT(_net_link_bridge, OID_AUTO, inherit_mac,
static VNET_DEFINE(int, allow_llz_overlap) = 0;
#define V_allow_llz_overlap VNET(allow_llz_overlap)
SYSCTL_INT(_net_link_bridge, OID_AUTO, allow_llz_overlap,
- CTLFLAG_VNET | CTLFLAG_RW | CTLFLAG_VNET, &VNET_NAME(allow_llz_overlap), 0,
+ CTLFLAG_RW | CTLFLAG_VNET, &VNET_NAME(allow_llz_overlap), 0,
"Allow overlap of link-local scope "
"zones of a bridge interface and the member interfaces");
@@ -1919,6 +1919,7 @@ bridge_enqueue(struct bridge_softc *sc, struct ifnet *dst_ifp, struct mbuf *m)
m->m_flags &= ~M_VLANTAG;
}
+ M_ASSERTPKTHDR(m); /* We shouldn't transmit mbuf without pkthdr */
if ((err = dst_ifp->if_transmit(dst_ifp, m))) {
m_freem(m0);
if_inc_counter(sc->sc_ifp, IFCOUNTER_OERRORS, 1);
@@ -3236,10 +3237,12 @@ bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct ifnet *ifp, int dir)
break;
/* check if we need to fragment the packet */
+ /* bridge_fragment generates a mbuf chain of packets */
+ /* that already include eth headers */
if (V_pfil_member && ifp != NULL && dir == PFIL_OUT) {
i = (*mp)->m_pkthdr.len;
if (i > ifp->if_mtu) {
- error = bridge_fragment(ifp, *mp, &eh2, snap,
+ error = bridge_fragment(ifp, mp, &eh2, snap,
&llc1);
return (error);
}
@@ -3478,56 +3481,77 @@ bad:
/*
* bridge_fragment:
*
- * Return a fragmented mbuf chain.
+ * Fragment mbuf chain in multiple packets and prepend ethernet header.
*/
static int
-bridge_fragment(struct ifnet *ifp, struct mbuf *m, struct ether_header *eh,
+bridge_fragment(struct ifnet *ifp, struct mbuf **mp, struct ether_header *eh,
int snap, struct llc *llc)
{
- struct mbuf *m0;
+ struct mbuf *m = *mp, *nextpkt = NULL, *mprev = NULL, *mcur = NULL;
struct ip *ip;
int error = -1;
if (m->m_len < sizeof(struct ip) &&
(m = m_pullup(m, sizeof(struct ip))) == NULL)
- goto out;
+ goto dropit;
ip = mtod(m, struct ip *);
m->m_pkthdr.csum_flags |= CSUM_IP;
error = ip_fragment(ip, &m, ifp->if_mtu, ifp->if_hwassist);
if (error)
- goto out;
+ goto dropit;
- /* walk the chain and re-add the Ethernet header */
- for (m0 = m; m0; m0 = m0->m_nextpkt) {
- if (error == 0) {
- if (snap) {
- M_PREPEND(m0, sizeof(struct llc), M_NOWAIT);
- if (m0 == NULL) {
- error = ENOBUFS;
- continue;
- }
- bcopy(llc, mtod(m0, caddr_t),
- sizeof(struct llc));
- }
- M_PREPEND(m0, ETHER_HDR_LEN, M_NOWAIT);
- if (m0 == NULL) {
+ /*
+ * Walk the chain and re-add the Ethernet header for
+ * each mbuf packet.
+ */
+ for (mcur = m; mcur; mcur = mcur->m_nextpkt) {
+ nextpkt = mcur->m_nextpkt;
+ mcur->m_nextpkt = NULL;
+ if (snap) {
+ M_PREPEND(mcur, sizeof(struct llc), M_NOWAIT);
+ if (mcur == NULL) {
error = ENOBUFS;
- continue;
+ if (mprev != NULL)
+ mprev->m_nextpkt = nextpkt;
+ goto dropit;
}
- bcopy(eh, mtod(m0, caddr_t), ETHER_HDR_LEN);
- } else
- m_freem(m);
- }
+ bcopy(llc, mtod(mcur, caddr_t),sizeof(struct llc));
+ }
+
+ M_PREPEND(mcur, ETHER_HDR_LEN, M_NOWAIT);
+ if (mcur == NULL) {
+ error = ENOBUFS;
+ if (mprev != NULL)
+ mprev->m_nextpkt = nextpkt;
+ goto dropit;
+ }
+ bcopy(eh, mtod(mcur, caddr_t), ETHER_HDR_LEN);
- if (error == 0)
- KMOD_IPSTAT_INC(ips_fragmented);
+ /*
+ * The previous two M_PREPEND could have inserted one or two
+ * mbufs in front so we have to update the previous packet's
+ * m_nextpkt.
+ */
+ mcur->m_nextpkt = nextpkt;
+ if (mprev != NULL)
+ mprev->m_nextpkt = mcur;
+ else {
+ /* The first mbuf in the original chain needs to be
+ * updated. */
+ *mp = mcur;
+ }
+ mprev = mcur;
+ }
+ KMOD_IPSTAT_INC(ips_fragmented);
return (error);
-out:
- if (m != NULL)
- m_freem(m);
+dropit:
+ for (mcur = *mp; mcur; mcur = m) { /* droping the full packet chain */
+ m = mcur->m_nextpkt;
+ m_freem(mcur);
+ }
return (error);
}
diff --git a/freebsd/sys/net/if_fddisubr.c b/freebsd/sys/net/if_fddisubr.c
index 9df882ec..98ac4cc3 100644
--- a/freebsd/sys/net/if_fddisubr.c
+++ b/freebsd/sys/net/if_fddisubr.c
@@ -277,7 +277,7 @@ fddi_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
if ((ifp->if_flags & IFF_SIMPLEX) && (loop_copy != -1)) {
if ((m->m_flags & M_BCAST) || (loop_copy > 0)) {
struct mbuf *n;
- n = m_copy(m, 0, (int)M_COPYALL);
+ n = m_copym(m, 0, M_COPYALL, M_NOWAIT);
(void) if_simloop(ifp, n, dst->sa_family,
FDDI_HDR_LEN);
} else if (bcmp(fh->fddi_dhost, fh->fddi_shost,
diff --git a/freebsd/sys/net/if_iso88025subr.c b/freebsd/sys/net/if_iso88025subr.c
index d26d0ebd..38322b23 100644
--- a/freebsd/sys/net/if_iso88025subr.c
+++ b/freebsd/sys/net/if_iso88025subr.c
@@ -366,7 +366,7 @@ iso88025_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
if ((ifp->if_flags & IFF_SIMPLEX) && (loop_copy != -1)) {
if ((m->m_flags & M_BCAST) || (loop_copy > 0)) {
struct mbuf *n;
- n = m_copy(m, 0, (int)M_COPYALL);
+ n = m_copym(m, 0, M_COPYALL, M_NOWAIT);
(void) if_simloop(ifp, n, dst->sa_family,
ISO88025_HDR_LEN);
} else if (bcmp(th->iso88025_dhost, th->iso88025_shost,
diff --git a/freebsd/sys/net/if_llatbl.c b/freebsd/sys/net/if_llatbl.c
index 20c0b9d2..a4741884 100644
--- a/freebsd/sys/net/if_llatbl.c
+++ b/freebsd/sys/net/if_llatbl.c
@@ -68,8 +68,13 @@ static VNET_DEFINE(SLIST_HEAD(, lltable), lltables) =
SLIST_HEAD_INITIALIZER(lltables);
#define V_lltables VNET(lltables)
-struct rwlock lltable_rwlock;
-RW_SYSINIT(lltable_rwlock, &lltable_rwlock, "lltable_rwlock");
+static struct rwlock lltable_list_lock;
+RW_SYSINIT(lltable_list_lock, &lltable_list_lock, "lltable_list_lock");
+#define LLTABLE_LIST_RLOCK() rw_rlock(&lltable_list_lock)
+#define LLTABLE_LIST_RUNLOCK() rw_runlock(&lltable_list_lock)
+#define LLTABLE_LIST_WLOCK() rw_wlock(&lltable_list_lock)
+#define LLTABLE_LIST_WUNLOCK() rw_wunlock(&lltable_list_lock)
+#define LLTABLE_LIST_LOCK_ASSERT() rw_assert(&lltable_list_lock, RA_LOCKED)
static void lltable_unlink(struct lltable *llt);
static void llentries_unlink(struct lltable *llt, struct llentries *head);
@@ -87,7 +92,7 @@ lltable_dump_af(struct lltable *llt, struct sysctl_req *wr)
{
int error;
- LLTABLE_LOCK_ASSERT();
+ LLTABLE_LIST_LOCK_ASSERT();
if (llt->llt_ifp->if_flags & IFF_LOOPBACK)
return (0);
@@ -110,7 +115,7 @@ lltable_sysctl_dumparp(int af, struct sysctl_req *wr)
struct lltable *llt;
int error = 0;
- LLTABLE_RLOCK();
+ LLTABLE_LIST_RLOCK();
SLIST_FOREACH(llt, &V_lltables, llt_link) {
if (llt->llt_af == af) {
error = lltable_dump_af(llt, wr);
@@ -119,7 +124,7 @@ lltable_sysctl_dumparp(int af, struct sysctl_req *wr)
}
}
done:
- LLTABLE_RUNLOCK();
+ LLTABLE_LIST_RUNLOCK();
return (error);
}
@@ -533,7 +538,7 @@ lltable_drain(int af)
struct llentry *lle;
register int i;
- LLTABLE_RLOCK();
+ LLTABLE_LIST_RLOCK();
SLIST_FOREACH(llt, &V_lltables, llt_link) {
if (llt->llt_af != af)
continue;
@@ -549,7 +554,7 @@ lltable_drain(int af)
}
}
}
- LLTABLE_RUNLOCK();
+ LLTABLE_LIST_RUNLOCK();
}
#endif
@@ -593,14 +598,14 @@ lltable_prefix_free(int af, struct sockaddr *addr, struct sockaddr *mask,
{
struct lltable *llt;
- LLTABLE_RLOCK();
+ LLTABLE_LIST_RLOCK();
SLIST_FOREACH(llt, &V_lltables, llt_link) {
if (llt->llt_af != af)
continue;
llt->llt_prefix_free(llt, addr, mask, flags);
}
- LLTABLE_RUNLOCK();
+ LLTABLE_LIST_RUNLOCK();
}
struct lltable *
@@ -634,18 +639,18 @@ void
lltable_link(struct lltable *llt)
{
- LLTABLE_WLOCK();
+ LLTABLE_LIST_WLOCK();
SLIST_INSERT_HEAD(&V_lltables, llt, llt_link);
- LLTABLE_WUNLOCK();
+ LLTABLE_LIST_WUNLOCK();
}
static void
lltable_unlink(struct lltable *llt)
{
- LLTABLE_WLOCK();
+ LLTABLE_LIST_WLOCK();
SLIST_REMOVE(&V_lltables, llt, lltable, llt_link);
- LLTABLE_WUNLOCK();
+ LLTABLE_LIST_WUNLOCK();
}
@@ -741,13 +746,13 @@ lla_rt_output(struct rt_msghdr *rtm, struct rt_addrinfo *info)
}
/* XXX linked list may be too expensive */
- LLTABLE_RLOCK();
+ LLTABLE_LIST_RLOCK();
SLIST_FOREACH(llt, &V_lltables, llt_link) {
if (llt->llt_af == dst->sa_family &&
llt->llt_ifp == ifp)
break;
}
- LLTABLE_RUNLOCK();
+ LLTABLE_LIST_RUNLOCK();
KASSERT(llt != NULL, ("Yep, ugly hacks are bad\n"));
error = 0;
diff --git a/freebsd/sys/net/if_llatbl.h b/freebsd/sys/net/if_llatbl.h
index 51de726a..5e89fea0 100644
--- a/freebsd/sys/net/if_llatbl.h
+++ b/freebsd/sys/net/if_llatbl.h
@@ -37,17 +37,9 @@ struct ifnet;
struct sysctl_req;
struct rt_msghdr;
struct rt_addrinfo;
-
struct llentry;
LIST_HEAD(llentries, llentry);
-extern struct rwlock lltable_rwlock;
-#define LLTABLE_RLOCK() rw_rlock(&lltable_rwlock)
-#define LLTABLE_RUNLOCK() rw_runlock(&lltable_rwlock)
-#define LLTABLE_WLOCK() rw_wlock(&lltable_rwlock)
-#define LLTABLE_WUNLOCK() rw_wunlock(&lltable_rwlock)
-#define LLTABLE_LOCK_ASSERT() rw_assert(&lltable_rwlock, RA_LOCKED)
-
#define LLE_MAX_LINKHDR 24 /* Full IB header */
/*
* Code referencing llentry must at least hold
diff --git a/freebsd/sys/net/if_loop.c b/freebsd/sys/net/if_loop.c
index aa5109eb..5ee82fc0 100644
--- a/freebsd/sys/net/if_loop.c
+++ b/freebsd/sys/net/if_loop.c
@@ -38,6 +38,7 @@
#include <rtems/bsd/local/opt_inet.h>
#include <rtems/bsd/local/opt_inet6.h>
+#include <rtems/bsd/local/opt_rss.h>
#include <rtems/bsd/sys/param.h>
#include <sys/systm.h>
@@ -226,6 +227,10 @@ looutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len);
+#ifdef RSS
+ M_HASHTYPE_CLEAR(m);
+#endif
+
/* BPF writes need to be handled specially. */
if (dst->sa_family == AF_UNSPEC || dst->sa_family == pseudo_AF_HDRCMPLT)
bcopy(dst->sa_data, &af, sizeof(af));
diff --git a/freebsd/sys/net/if_var.h b/freebsd/sys/net/if_var.h
index ec3719d4..6ddb6c7b 100644
--- a/freebsd/sys/net/if_var.h
+++ b/freebsd/sys/net/if_var.h
@@ -178,9 +178,6 @@ struct if_encap_req {
/*
* Structure defining a network interface.
- *
- * Size ILP32: 592 (approx)
- * LP64: 1048 (approx)
*/
struct ifnet {
/* General book keeping of interface lists. */
@@ -316,8 +313,6 @@ struct ifnet {
};
/* for compatibility with other BSDs */
-#define if_addrlist if_addrhead
-#define if_list if_link
#define if_name(ifp) ((ifp)->if_xname)
/*
@@ -451,9 +446,6 @@ struct ifaddr {
counter_u64_t ifa_obytes;
};
-/* For compatibility with other BSDs. SCTP uses it. */
-#define ifa_list ifa_link
-
struct ifaddr * ifa_alloc(size_t size, int flags);
void ifa_free(struct ifaddr *ifa);
void ifa_ref(struct ifaddr *ifa);
@@ -504,7 +496,7 @@ extern struct sx ifnet_sxlock;
/*
* Look up an ifnet given its index; the _ref variant also acquires a
* reference that must be freed using if_rele(). It is almost always a bug
- * to call ifnet_byindex() instead if ifnet_byindex_ref().
+ * to call ifnet_byindex() instead of ifnet_byindex_ref().
*/
struct ifnet *ifnet_byindex(u_short idx);
struct ifnet *ifnet_byindex_locked(u_short idx);
diff --git a/freebsd/sys/net/pfkeyv2.h b/freebsd/sys/net/pfkeyv2.h
index c9b27695..35348819 100644
--- a/freebsd/sys/net/pfkeyv2.h
+++ b/freebsd/sys/net/pfkeyv2.h
@@ -283,6 +283,14 @@ struct sadb_x_nat_t_frag {
};
_Static_assert(sizeof(struct sadb_x_nat_t_frag) == 8, "struct size mismatch");
+/* Additional large replay window support
+ */
+struct sadb_x_sa_replay {
+ u_int16_t sadb_x_sa_replay_len;
+ u_int16_t sadb_x_sa_replay_exttype;
+ u_int32_t sadb_x_sa_replay_replay; /* in packets */
+};
+_Static_assert(sizeof(struct sadb_x_sa_replay) == 8, "struct size mismatch");
#define SADB_EXT_RESERVED 0
#define SADB_EXT_SA 1
@@ -311,7 +319,8 @@ _Static_assert(sizeof(struct sadb_x_nat_t_frag) == 8, "struct size mismatch");
#define SADB_X_EXT_NAT_T_OAI 23 /* Peer's NAT_OA for src of SA. */
#define SADB_X_EXT_NAT_T_OAR 24 /* Peer's NAT_OA for dst of SA. */
#define SADB_X_EXT_NAT_T_FRAG 25 /* Manual MTU override. */
-#define SADB_EXT_MAX 25
+#define SADB_X_EXT_SA_REPLAY 26 /* Replay window override. */
+#define SADB_EXT_MAX 26
#define SADB_SATYPE_UNSPEC 0
#define SADB_SATYPE_AH 2
diff --git a/freebsd/sys/net/raw_usrreq.c b/freebsd/sys/net/raw_usrreq.c
index e170ad74..6e9668f3 100644
--- a/freebsd/sys/net/raw_usrreq.c
+++ b/freebsd/sys/net/raw_usrreq.c
@@ -97,7 +97,7 @@ raw_input_ext(struct mbuf *m0, struct sockproto *proto, struct sockaddr *src,
continue;
if (last) {
struct mbuf *n;
- n = m_copy(m, 0, (int)M_COPYALL);
+ n = m_copym(m, 0, M_COPYALL, M_NOWAIT);
if (n) {
if (sbappendaddr(&last->so_rcv, src,
n, (struct mbuf *)0) == 0)
diff --git a/freebsd/sys/net/route.c b/freebsd/sys/net/route.c
index 3eb05b94..a851efa8 100644
--- a/freebsd/sys/net/route.c
+++ b/freebsd/sys/net/route.c
@@ -362,7 +362,7 @@ rt_table_init(int offset)
rh->head.rnh_masks = &rh->rmhead;
/* Init locks */
- rw_init(&rh->rib_lock, "rib head lock");
+ RIB_LOCK_INIT(rh);
/* Finally, set base callbacks */
rh->rnh_addaddr = rn_addroute;
@@ -394,7 +394,7 @@ rt_table_destroy(struct rib_head *rh)
rn_walktree(&rh->rmhead.head, rt_freeentry, &rh->rmhead.head);
/* Assume table is already empty */
- rw_destroy(&rh->rib_lock);
+ RIB_LOCK_DESTROY(rh);
free(rh, M_RTABLE);
}
@@ -499,9 +499,8 @@ rtalloc1_fib(struct sockaddr *dst, int report, u_long ignflags,
RIB_RUNLOCK(rh);
/*
- * Either we hit the root or couldn't find any match,
- * Which basically means
- * "caint get there frm here"
+ * Either we hit the root or could not find any match,
+ * which basically means: "cannot get there from here".
*/
miss:
V_rtstat.rts_unreach++;
diff --git a/freebsd/sys/net/route_var.h b/freebsd/sys/net/route_var.h
index a8ef56a5..914bcfe2 100644
--- a/freebsd/sys/net/route_var.h
+++ b/freebsd/sys/net/route_var.h
@@ -48,6 +48,8 @@ struct rib_head {
struct radix_mask_head rmhead; /* masks radix head */
};
+#define RIB_LOCK_INIT(rh) rw_init(&(rh)->rib_lock, "rib head lock")
+#define RIB_LOCK_DESTROY(rh) rw_destroy(&(rh)->rib_lock)
#define RIB_RLOCK(rh) rw_rlock(&(rh)->rib_lock)
#define RIB_RUNLOCK(rh) rw_runlock(&(rh)->rib_lock)
#define RIB_WLOCK(rh) rw_wlock(&(rh)->rib_lock)
diff --git a/freebsd/sys/net/rtsock.c b/freebsd/sys/net/rtsock.c
index 1e69bcdf..97b92127 100644
--- a/freebsd/sys/net/rtsock.c
+++ b/freebsd/sys/net/rtsock.c
@@ -1578,8 +1578,8 @@ sysctl_dumpentry(struct radix_node *rn, void *vw)
}
static int
-sysctl_iflist_ifml(struct ifnet *ifp, struct rt_addrinfo *info,
- struct walkarg *w, int len)
+sysctl_iflist_ifml(struct ifnet *ifp, const struct if_data *src_ifd,
+ struct rt_addrinfo *info, struct walkarg *w, int len)
{
struct if_msghdrl *ifm;
struct if_data *ifd;
@@ -1610,14 +1610,14 @@ sysctl_iflist_ifml(struct ifnet *ifp, struct rt_addrinfo *info,
ifd = &ifm->ifm_data;
}
- if_data_copy(ifp, ifd);
+ memcpy(ifd, src_ifd, sizeof(*ifd));
return (SYSCTL_OUT(w->w_req, (caddr_t)ifm, len));
}
static int
-sysctl_iflist_ifm(struct ifnet *ifp, struct rt_addrinfo *info,
- struct walkarg *w, int len)
+sysctl_iflist_ifm(struct ifnet *ifp, const struct if_data *src_ifd,
+ struct rt_addrinfo *info, struct walkarg *w, int len)
{
struct if_msghdr *ifm;
struct if_data *ifd;
@@ -1642,7 +1642,7 @@ sysctl_iflist_ifm(struct ifnet *ifp, struct rt_addrinfo *info,
ifd = &ifm->ifm_data;
}
- if_data_copy(ifp, ifd);
+ memcpy(ifd, src_ifd, sizeof(*ifd));
return (SYSCTL_OUT(w->w_req, (caddr_t)ifm, len));
}
@@ -1717,15 +1717,18 @@ sysctl_iflist(int af, struct walkarg *w)
{
struct ifnet *ifp;
struct ifaddr *ifa;
+ struct if_data ifd;
struct rt_addrinfo info;
int len, error = 0;
struct sockaddr_storage ss;
bzero((caddr_t)&info, sizeof(info));
+ bzero(&ifd, sizeof(ifd));
IFNET_RLOCK_NOSLEEP();
TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (w->w_arg && w->w_arg != ifp->if_index)
continue;
+ if_data_copy(ifp, &ifd);
IF_ADDR_RLOCK(ifp);
ifa = ifp->if_addr;
info.rti_info[RTAX_IFP] = ifa->ifa_addr;
@@ -1735,9 +1738,11 @@ sysctl_iflist(int af, struct walkarg *w)
info.rti_info[RTAX_IFP] = NULL;
if (w->w_req && w->w_tmem) {
if (w->w_op == NET_RT_IFLISTL)
- error = sysctl_iflist_ifml(ifp, &info, w, len);
+ error = sysctl_iflist_ifml(ifp, &ifd, &info, w,
+ len);
else
- error = sysctl_iflist_ifm(ifp, &info, w, len);
+ error = sysctl_iflist_ifm(ifp, &ifd, &info, w,
+ len);
if (error)
goto done;
}
@@ -1780,13 +1785,15 @@ done:
static int
sysctl_ifmalist(int af, struct walkarg *w)
{
- struct ifnet *ifp;
- struct ifmultiaddr *ifma;
- struct rt_addrinfo info;
- int len, error = 0;
+ struct rt_addrinfo info;
struct ifaddr *ifa;
+ struct ifmultiaddr *ifma;
+ struct ifnet *ifp;
+ int error, len;
+ error = 0;
bzero((caddr_t)&info, sizeof(info));
+
IFNET_RLOCK_NOSLEEP();
TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (w->w_arg && w->w_arg != ifp->if_index)
@@ -1806,7 +1813,7 @@ sysctl_ifmalist(int af, struct walkarg *w)
ifma->ifma_lladdr : NULL;
error = rtsock_msg_buffer(RTM_NEWMADDR, &info, w, &len);
if (error != 0)
- goto done;
+ break;
if (w->w_req && w->w_tmem) {
struct ifma_msghdr *ifmam;
@@ -1815,15 +1822,14 @@ sysctl_ifmalist(int af, struct walkarg *w)
ifmam->ifmam_flags = 0;
ifmam->ifmam_addrs = info.rti_addrs;
error = SYSCTL_OUT(w->w_req, w->w_tmem, len);
- if (error) {
- IF_ADDR_RUNLOCK(ifp);
- goto done;
- }
+ if (error != 0)
+ break;
}
}
IF_ADDR_RUNLOCK(ifp);
+ if (error != 0)
+ break;
}
-done:
IFNET_RUNLOCK_NOSLEEP();
return (error);
}