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

Collapse All | Expand All

(-)if_wg.c (-4 / +38 lines)
Lines 93-98 Link Here
93
93
94
#define DPRINTF(sc, ...) if (sc->sc_ifp->if_flags & IFF_DEBUG) if_printf(sc->sc_ifp, ##__VA_ARGS__)
94
#define DPRINTF(sc, ...) if (sc->sc_ifp->if_flags & IFF_DEBUG) if_printf(sc->sc_ifp, ##__VA_ARGS__)
95
95
96
#if __FreeBSD_version < 1400059
97
#define sbcreatecontrol(p, size, type, level)	sbcreatecontrol(p, size, type, level, M_WAITOK)
98
#endif
99
96
/* First byte indicating packet type on the wire */
100
/* First byte indicating packet type on the wire */
97
#define WG_PKT_INITIATION htole32(1)
101
#define WG_PKT_INITIATION htole32(1)
98
#define WG_PKT_RESPONSE htole32(2)
102
#define WG_PKT_RESPONSE htole32(2)
Lines 377-383 Link Here
377
static int wg_queue_both(struct wg_queue *, struct wg_queue *, struct wg_packet *);
381
static int wg_queue_both(struct wg_queue *, struct wg_queue *, struct wg_packet *);
378
static struct wg_packet *wg_queue_dequeue_serial(struct wg_queue *);
382
static struct wg_packet *wg_queue_dequeue_serial(struct wg_queue *);
379
static struct wg_packet *wg_queue_dequeue_parallel(struct wg_queue *);
383
static struct wg_packet *wg_queue_dequeue_parallel(struct wg_queue *);
384
#if __FreeBSD_version >= 1400057
385
static bool wg_input(struct mbuf *, int, struct inpcb *, const struct sockaddr *, void *);
386
#else
380
static void wg_input(struct mbuf *, int, struct inpcb *, const struct sockaddr *, void *);
387
static void wg_input(struct mbuf *, int, struct inpcb *, const struct sockaddr *, void *);
388
#endif
381
static void wg_peer_send_staged(struct wg_peer *);
389
static void wg_peer_send_staged(struct wg_peer *);
382
static int wg_clone_create(struct if_clone *, int, caddr_t);
390
static int wg_clone_create(struct if_clone *, int, caddr_t);
383
static void wg_qflush(struct ifnet *);
391
static void wg_qflush(struct ifnet *);
Lines 891-905 Link Here
891
	/* Get local control address before locking */
899
	/* Get local control address before locking */
892
	if (e->e_remote.r_sa.sa_family == AF_INET) {
900
	if (e->e_remote.r_sa.sa_family == AF_INET) {
893
		if (e->e_local.l_in.s_addr != INADDR_ANY)
901
		if (e->e_local.l_in.s_addr != INADDR_ANY)
894
			control = sbcreatecontrol((caddr_t)&e->e_local.l_in,
902
			control = sbcreatecontrol(&e->e_local.l_in,
895
			    sizeof(struct in_addr), IP_SENDSRCADDR,
903
			    sizeof(struct in_addr), IP_SENDSRCADDR,
896
			    IPPROTO_IP);
904
			    IPPROTO_IP, M_WAITOK);
897
#ifdef INET6
905
#ifdef INET6
898
	} else if (e->e_remote.r_sa.sa_family == AF_INET6) {
906
	} else if (e->e_remote.r_sa.sa_family == AF_INET6) {
899
		if (!IN6_IS_ADDR_UNSPECIFIED(&e->e_local.l_in6))
907
		if (!IN6_IS_ADDR_UNSPECIFIED(&e->e_local.l_in6))
900
			control = sbcreatecontrol((caddr_t)&e->e_local.l_pktinfo6,
908
			control = sbcreatecontrol(&e->e_local.l_pktinfo6,
901
			    sizeof(struct in6_pktinfo), IPV6_PKTINFO,
909
			    sizeof(struct in6_pktinfo), IPV6_PKTINFO,
902
			    IPPROTO_IPV6);
910
			    IPPROTO_IPV6, M_WAITOK);
903
#endif
911
#endif
904
	} else {
912
	} else {
905
		m_freem(m);
913
		m_freem(m);
Lines 1946-1954 Link Here
1946
	return (pkt);
1954
	return (pkt);
1947
}
1955
}
1948
1956
1957
#if __FreeBSD_version >= 1400057
1958
static bool
1959
wg_input(struct mbuf *m, int offset, struct inpcb *inpcb,
1960
    const struct sockaddr *sa, void *_sc)
1961
#else
1949
static void
1962
static void
1950
wg_input(struct mbuf *m, int offset, struct inpcb *inpcb,
1963
wg_input(struct mbuf *m, int offset, struct inpcb *inpcb,
1951
    const struct sockaddr *sa, void *_sc)
1964
    const struct sockaddr *sa, void *_sc)
1965
#endif
1952
{
1966
{
1953
	const struct sockaddr_in	*sin;
1967
	const struct sockaddr_in	*sin;
1954
	const struct sockaddr_in6	*sin6;
1968
	const struct sockaddr_in6	*sin6;
Lines 1965-1971 Link Here
1965
	m = m_unshare(m, M_NOWAIT);
1979
	m = m_unshare(m, M_NOWAIT);
1966
	if (!m) {
1980
	if (!m) {
1967
		if_inc_counter(sc->sc_ifp, IFCOUNTER_IQDROPS, 1);
1981
		if_inc_counter(sc->sc_ifp, IFCOUNTER_IQDROPS, 1);
1982
#if __FreeBSD_version >= 1400057
1983
		return true;
1984
#else
1968
		return;
1985
		return;
1986
#endif
1969
	}
1987
	}
1970
1988
1971
	/* Caller provided us with `sa`, no need for this header. */
1989
	/* Caller provided us with `sa`, no need for this header. */
Lines 1974-1986 Link Here
1974
	/* Pullup enough to read packet type */
1992
	/* Pullup enough to read packet type */
1975
	if ((m = m_pullup(m, sizeof(uint32_t))) == NULL) {
1993
	if ((m = m_pullup(m, sizeof(uint32_t))) == NULL) {
1976
		if_inc_counter(sc->sc_ifp, IFCOUNTER_IQDROPS, 1);
1994
		if_inc_counter(sc->sc_ifp, IFCOUNTER_IQDROPS, 1);
1995
#if __FreeBSD_version >= 1400057
1996
		return true;
1997
#else
1977
		return;
1998
		return;
1999
#endif
1978
	}
2000
	}
1979
2001
1980
	if ((pkt = wg_packet_alloc(m)) == NULL) {
2002
	if ((pkt = wg_packet_alloc(m)) == NULL) {
1981
		if_inc_counter(sc->sc_ifp, IFCOUNTER_IQDROPS, 1);
2003
		if_inc_counter(sc->sc_ifp, IFCOUNTER_IQDROPS, 1);
1982
		m_freem(m);
2004
		m_freem(m);
2005
#if __FreeBSD_version >= 1400057
2006
		return true;
2007
#else
1983
		return;
2008
		return;
2009
#endif
1984
	}
2010
	}
1985
2011
1986
	/* Save send/recv address and port for later. */
2012
	/* Save send/recv address and port for later. */
Lines 2027-2037 Link Here
2027
	} else {
2053
	} else {
2028
		goto error;
2054
		goto error;
2029
	}
2055
	}
2056
#if __FreeBSD_version >= 1400057
2057
	return true;
2058
#else
2030
	return;
2059
	return;
2060
#endif
2031
error:
2061
error:
2032
	if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, 1);
2062
	if_inc_counter(sc->sc_ifp, IFCOUNTER_IERRORS, 1);
2033
	wg_packet_free(pkt);
2063
	wg_packet_free(pkt);
2064
#if __FreeBSD_version >= 1400057
2065
	return true;
2066
#else
2034
	return;
2067
	return;
2068
#endif
2035
}
2069
}
2036
2070
2037
static void
2071
static void

Return to bug 264105