View | Details | Raw Unified | Return to bug 264105 | Differences between
and this patch

Collapse All | Expand All

(-)files/patch-if__wg.c (-4 / +41 lines)
Lines 12-18 Link Here
12
 static void wg_peer_send_staged(struct wg_peer *);
12
 static void wg_peer_send_staged(struct wg_peer *);
13
 static int wg_clone_create(struct if_clone *, int, caddr_t);
13
 static int wg_clone_create(struct if_clone *, int, caddr_t);
14
 static void wg_qflush(struct ifnet *);
14
 static void wg_qflush(struct ifnet *);
15
@@ -1946,9 +1950,15 @@ wg_queue_dequeue_parallel(struct wg_queue *parallel)
15
@@ -889,10 +893,28 @@ wg_send(struct wg_softc *sc, struct wg_endpoint *e, st
16
 	size_t len = m->m_pkthdr.len;
17
 
18
 	/* Get local control address before locking */
19
+#if __FreeBSD_version >= 1400059
20
 	if (e->e_remote.r_sa.sa_family == AF_INET) {
21
 		if (e->e_local.l_in.s_addr != INADDR_ANY)
22
 			control = sbcreatecontrol((caddr_t)&e->e_local.l_in,
23
 			    sizeof(struct in_addr), IP_SENDSRCADDR,
24
+			    IPPROTO_IP, M_WAITOK);
25
+#ifdef INET6
26
+	} else if (e->e_remote.r_sa.sa_family == AF_INET6) {
27
+		if (!IN6_IS_ADDR_UNSPECIFIED(&e->e_local.l_in6))
28
+			control = sbcreatecontrol((caddr_t)&e->e_local.l_pktinfo6,
29
+			    sizeof(struct in6_pktinfo), IPV6_PKTINFO,
30
+			    IPPROTO_IPV6, M_WAITOK);
31
+#endif
32
+	} else {
33
+		m_freem(m);
34
+		return (EAFNOSUPPORT);
35
+	}
36
+#else
37
+	if (e->e_remote.r_sa.sa_family == AF_INET) {
38
+		if (e->e_local.l_in.s_addr != INADDR_ANY)
39
+			control = sbcreatecontrol((caddr_t)&e->e_local.l_in,
40
+			    sizeof(struct in_addr), IP_SENDSRCADDR,
41
 			    IPPROTO_IP);
42
 #ifdef INET6
43
 	} else if (e->e_remote.r_sa.sa_family == AF_INET6) {
44
@@ -905,6 +927,7 @@ wg_send(struct wg_softc *sc, struct wg_endpoint *e, st
45
 		m_freem(m);
46
 		return (EAFNOSUPPORT);
47
 	}
48
+#endif
49
 
50
 	/* Get remote address */
51
 	sa = &e->e_remote.r_sa;
52
@@ -1946,9 +1969,15 @@ wg_queue_dequeue_parallel(struct wg_queue *parallel)
16
 	return (pkt);
53
 	return (pkt);
17
 }
54
 }
18
 
55
 
Lines 28-34 Link Here
28
 {
65
 {
29
 	const struct sockaddr_in	*sin;
66
 	const struct sockaddr_in	*sin;
30
 	const struct sockaddr_in6	*sin6;
67
 	const struct sockaddr_in6	*sin6;
31
@@ -1965,7 +1975,11 @@ wg_input(struct mbuf *m, int offset, struct inpcb *inp
68
@@ -1965,7 +1994,11 @@ wg_input(struct mbuf *m, int offset, struct inpcb *inp
32
 	m = m_unshare(m, M_NOWAIT);
69
 	m = m_unshare(m, M_NOWAIT);
33
 	if (!m) {
70
 	if (!m) {
34
 		if_inc_counter(sc->sc_ifp, IFCOUNTER_IQDROPS, 1);
71
 		if_inc_counter(sc->sc_ifp, IFCOUNTER_IQDROPS, 1);
Lines 40-46 Link Here
40
 	}
77
 	}
41
 
78
 
42
 	/* Caller provided us with `sa`, no need for this header. */
79
 	/* Caller provided us with `sa`, no need for this header. */
43
@@ -1974,13 +1988,21 @@ wg_input(struct mbuf *m, int offset, struct inpcb *inp
80
@@ -1974,13 +2007,21 @@ wg_input(struct mbuf *m, int offset, struct inpcb *inp
44
 	/* Pullup enough to read packet type */
81
 	/* Pullup enough to read packet type */
45
 	if ((m = m_pullup(m, sizeof(uint32_t))) == NULL) {
82
 	if ((m = m_pullup(m, sizeof(uint32_t))) == NULL) {
46
 		if_inc_counter(sc->sc_ifp, IFCOUNTER_IQDROPS, 1);
83
 		if_inc_counter(sc->sc_ifp, IFCOUNTER_IQDROPS, 1);
Lines 62-68 Link Here
62
 	}
99
 	}
63
 
100
 
64
 	/* Save send/recv address and port for later. */
101
 	/* Save send/recv address and port for later. */
65
@@ -2027,11 +2049,19 @@ wg_input(struct mbuf *m, int offset, struct inpcb *inp
102
@@ -2027,11 +2068,19 @@ wg_input(struct mbuf *m, int offset, struct inpcb *inp
66
 	} else {
103
 	} else {
67
 		goto error;
104
 		goto error;
68
 	}
105
 	}

Return to bug 264105