Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Jan 2015 06:19:31 +0000 (UTC)
From:      Bryan Venteicher <bryanv@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r277789 - in stable/10/sys: netinet netinet6
Message-ID:  <201501270619.t0R6JVFl039453@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bryanv
Date: Tue Jan 27 06:19:30 2015
New Revision: 277789
URL: https://svnweb.freebsd.org/changeset/base/277789

Log:
  MFC r272886:
  
    Add context pointer and source address to the UDP tunnel callback
  
    These are needed for the forthcoming vxlan implementation. The context
    pointer means we do not have to use a spare pointer field in the inpcb,
    and the source address is required to populate vxlan's forwarding table.

Modified:
  stable/10/sys/netinet/sctputil.c
  stable/10/sys/netinet/udp_usrreq.c
  stable/10/sys/netinet/udp_var.h
  stable/10/sys/netinet6/udp6_usrreq.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netinet/sctputil.c
==============================================================================
--- stable/10/sys/netinet/sctputil.c	Tue Jan 27 05:34:46 2015	(r277788)
+++ stable/10/sys/netinet/sctputil.c	Tue Jan 27 06:19:30 2015	(r277789)
@@ -6832,7 +6832,8 @@ sctp_log_trace(uint32_t subsys, const ch
 
 #endif
 static void
-sctp_recv_udp_tunneled_packet(struct mbuf *m, int off, struct inpcb *ignored)
+sctp_recv_udp_tunneled_packet(struct mbuf *m, int off, struct inpcb *ignored,
+    const struct sockaddr *sa SCTP_UNUSED, void *ctx SCTP_UNUSED)
 {
 	struct ip *iph;
 
@@ -6968,7 +6969,7 @@ sctp_over_udp_start(void)
 	}
 	/* Call the special UDP hook. */
 	if ((ret = udp_set_kernel_tunneling(SCTP_BASE_INFO(udp4_tun_socket),
-	    sctp_recv_udp_tunneled_packet))) {
+	    sctp_recv_udp_tunneled_packet, NULL))) {
 		sctp_over_udp_stop();
 		return (ret);
 	}
@@ -6992,7 +6993,7 @@ sctp_over_udp_start(void)
 	}
 	/* Call the special UDP hook. */
 	if ((ret = udp_set_kernel_tunneling(SCTP_BASE_INFO(udp6_tun_socket),
-	    sctp_recv_udp_tunneled_packet))) {
+	    sctp_recv_udp_tunneled_packet, NULL))) {
 		sctp_over_udp_stop();
 		return (ret);
 	}

Modified: stable/10/sys/netinet/udp_usrreq.c
==============================================================================
--- stable/10/sys/netinet/udp_usrreq.c	Tue Jan 27 05:34:46 2015	(r277788)
+++ stable/10/sys/netinet/udp_usrreq.c	Tue Jan 27 06:19:30 2015	(r277789)
@@ -303,7 +303,8 @@ udp_append(struct inpcb *inp, struct ip 
 	 */
 	up = intoudpcb(inp);
 	if (up->u_tun_func != NULL) {
-		(*up->u_tun_func)(n, off, inp);
+		(*up->u_tun_func)(n, off, inp, (struct sockaddr *)udp_in,
+		    up->u_tun_ctx);
 		return;
 	}
 
@@ -1624,7 +1625,7 @@ udp_attach(struct socket *so, int proto,
 #endif /* INET */
 
 int
-udp_set_kernel_tunneling(struct socket *so, udp_tun_func_t f)
+udp_set_kernel_tunneling(struct socket *so, udp_tun_func_t f, void *ctx)
 {
 	struct inpcb *inp;
 	struct udpcb *up;
@@ -1640,6 +1641,7 @@ udp_set_kernel_tunneling(struct socket *
 		return (EBUSY);
 	}
 	up->u_tun_func = f;
+	up->u_tun_ctx = ctx;
 	INP_WUNLOCK(inp);
 	return (0);
 }

Modified: stable/10/sys/netinet/udp_var.h
==============================================================================
--- stable/10/sys/netinet/udp_var.h	Tue Jan 27 05:34:46 2015	(r277788)
+++ stable/10/sys/netinet/udp_var.h	Tue Jan 27 06:19:30 2015	(r277789)
@@ -55,7 +55,8 @@ struct udpiphdr {
 struct inpcb;
 struct mbuf;
 
-typedef void(*udp_tun_func_t)(struct mbuf *, int off, struct inpcb *);
+typedef void(*udp_tun_func_t)(struct mbuf *, int off, struct inpcb *,
+			      const struct sockaddr *, void *);
 
 /*
  * UDP control block; one per udp.
@@ -65,6 +66,7 @@ struct udpcb {
 	u_int		u_flags;	/* Generic UDP flags. */
 	uint16_t	u_rxcslen;	/* Coverage for incoming datagrams. */
 	uint16_t	u_txcslen;	/* Coverage for outgoing datagrams. */
+	void 		*u_tun_ctx;	/* Tunneling callback context. */
 };
 
 #define	intoudpcb(ip)	((struct udpcb *)(ip)->inp_ppcb)
@@ -176,7 +178,8 @@ void		udplite_input(struct mbuf *, int);
 struct inpcb	*udp_notify(struct inpcb *inp, int errno);
 int		udp_shutdown(struct socket *so);
 
-int		udp_set_kernel_tunneling(struct socket *so, udp_tun_func_t f);
+int		udp_set_kernel_tunneling(struct socket *so, udp_tun_func_t f,
+					 void *ctx);
 
 #endif /* _KERNEL */
 

Modified: stable/10/sys/netinet6/udp6_usrreq.c
==============================================================================
--- stable/10/sys/netinet6/udp6_usrreq.c	Tue Jan 27 05:34:46 2015	(r277788)
+++ stable/10/sys/netinet6/udp6_usrreq.c	Tue Jan 27 06:19:30 2015	(r277789)
@@ -148,7 +148,8 @@ udp6_append(struct inpcb *inp, struct mb
 	 */
 	up = intoudpcb(inp);
 	if (up->u_tun_func != NULL) {
-		(*up->u_tun_func)(n, off, inp);
+		(*up->u_tun_func)(n, off, inp, (struct sockaddr *)fromsa,
+		    up->u_tun_ctx);
 		return;
 	}
 #ifdef IPSEC



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201501270619.t0R6JVFl039453>