From owner-svn-src-all@FreeBSD.ORG Fri Oct 10 06:09:01 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4101148C; Fri, 10 Oct 2014 06:09:01 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2CB68810; Fri, 10 Oct 2014 06:09:01 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9A6917Q067755; Fri, 10 Oct 2014 06:09:01 GMT (envelope-from bryanv@FreeBSD.org) Received: (from bryanv@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9A690NU067686; Fri, 10 Oct 2014 06:09:00 GMT (envelope-from bryanv@FreeBSD.org) Message-Id: <201410100609.s9A690NU067686@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: bryanv set sender to bryanv@FreeBSD.org using -f From: Bryan Venteicher Date: Fri, 10 Oct 2014 06:09:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r272886 - in head/sys: netinet netinet6 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Oct 2014 06:09:01 -0000 Author: bryanv Date: Fri Oct 10 06:08:59 2014 New Revision: 272886 URL: https://svnweb.freebsd.org/changeset/base/272886 Log: 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. While I highly doubt there is an out of tree consumer of the UDP tunneling callback, this change may be a difficult to eventually MFC. Phabricator: https://reviews.freebsd.org/D383 Reviewed by: gnn Modified: head/sys/netinet/sctputil.c head/sys/netinet/udp_usrreq.c head/sys/netinet/udp_var.h head/sys/netinet6/udp6_usrreq.c Modified: head/sys/netinet/sctputil.c ============================================================================== --- head/sys/netinet/sctputil.c Fri Oct 10 03:20:12 2014 (r272885) +++ head/sys/netinet/sctputil.c Fri Oct 10 06:08:59 2014 (r272886) @@ -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: head/sys/netinet/udp_usrreq.c ============================================================================== --- head/sys/netinet/udp_usrreq.c Fri Oct 10 03:20:12 2014 (r272885) +++ head/sys/netinet/udp_usrreq.c Fri Oct 10 06:08:59 2014 (r272886) @@ -312,7 +312,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; } @@ -1717,7 +1718,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; @@ -1733,6 +1734,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: head/sys/netinet/udp_var.h ============================================================================== --- head/sys/netinet/udp_var.h Fri Oct 10 03:20:12 2014 (r272885) +++ head/sys/netinet/udp_var.h Fri Oct 10 06:08:59 2014 (r272886) @@ -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: head/sys/netinet6/udp6_usrreq.c ============================================================================== --- head/sys/netinet6/udp6_usrreq.c Fri Oct 10 03:20:12 2014 (r272885) +++ head/sys/netinet6/udp6_usrreq.c Fri Oct 10 06:08:59 2014 (r272886) @@ -150,7 +150,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