Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Aug 2016 07:49:20 +0200
From:      Marko Zec <zec@fer.hr>
To:        Ryan Stone <rstone@freebsd.org>
Cc:        <src-committers@freebsd.org>, <svn-src-all@freebsd.org>, <svn-src-head@freebsd.org>
Subject:   Re: svn commit: r304436 - in head: . sys/netinet
Message-ID:  <20160819074920.52c46f57@x23>
In-Reply-To: <201608182259.u7IMx5oW002018@repo.freebsd.org>
References:  <201608182259.u7IMx5oW002018@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 18 Aug 2016 22:59:05 +0000
Ryan Stone <rstone@freebsd.org> wrote:

> Author: rstone
> Date: Thu Aug 18 22:59:05 2016
> New Revision: 304436
> URL: https://svnweb.freebsd.org/changeset/base/304436
> 
> Log:
>   Don't check for broadcast IPs on non-bcast pkts
>   
>   in_broadcast() can be quite expensive, so skip calling it if the
>   incoming mbuf wasn't sent to a broadcast L2 address in the first
>   place.
>   
>   Reviewed by: gnn
>   MFC after: 2 months
>   Sponsored by: EMC / Isilon Storage Division
>   Differential Revision: https://reviews.freebsd.org/D7309
> 
> Modified:
>   head/UPDATING
>   head/sys/netinet/udp_usrreq.c
> 
> Modified: head/UPDATING
> ==============================================================================
> --- head/UPDATING	Thu Aug 18 22:59:00 2016	(r304435)
> +++ head/UPDATING	Thu Aug 18 22:59:05 2016	(r304436)
> @@ -32,6 +32,14 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12
>  	"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
>  
>  20160818:
> +	The UDP receive code has been updated to only treat incoming
> UDP
> +	packets that were addressed to an L2 broadcast address as L3
> +	broadcast packets.  It is not expected that this will affect
> any
> +	standards-conforming UDP application.  The new behaviour can
> be
> +	disabled by setting the sysctl net.inet.udp.require_l2_bcast
> to
> +	0.
> +
> +20160818:
>  	Remove the openbsd_poll system call.
>          __FreeBSD_version has been bumped because of this.
>  
> 
> Modified: head/sys/netinet/udp_usrreq.c
> ==============================================================================
> --- head/sys/netinet/udp_usrreq.c	Thu Aug 18 22:59:00
> 2016	(r304435) +++ head/sys/netinet/udp_usrreq.c	Thu
> Aug 18 22:59:05 2016	(r304436) @@ -126,6 +126,11 @@
> SYSCTL_INT(_net_inet_udp, OID_AUTO, blac &VNET_NAME(udp_blackhole), 0,
>      "Do not send port unreachables for refused connects");
>  
> +static VNET_DEFINE(int, udp_require_l2_bcast) = 1;
> +SYSCTL_INT(_net_inet_udp, OID_AUTO, require_l2_bcast, CTLFLAG_VNET |
> CTLFLAG_RW,
> +    &VNET_NAME(udp_require_l2_bcast), 0,
> +    "Only treat packets sent to an L2 broadcast address as broadcast
> packets"); +
>  u_long	udp_sendspace = 9216;		/* really max
> datagram size */ SYSCTL_ULONG(_net_inet_udp, UDPCTL_MAXDGRAM,
> maxdgram, CTLFLAG_RW, &udp_sendspace, 0, "Maximum outgoing UDP
> datagram size"); @@ -523,7 +528,8 @@ udp_input(struct mbuf **mp, int
> *offp, i 
>  	pcbinfo = udp_get_inpcbinfo(proto);
>  	if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) ||
> -	    in_broadcast(ip->ip_dst, ifp)) {
> +	    ((!VNET_NAME(udp_require_l2_bcast) || m->m_flags &
> M_BCAST) &&
> +	    in_broadcast(ip->ip_dst, ifp))) {
>  		struct inpcb *last;
>  		struct inpcbhead *pcblist;
>  		struct ip_moptions *imo;
> 

VNET_NAME() macros should be used only within SYSCTL_* macros,
otherwise (if I recall it correctly) this won't work with options
VIMAGE enabled, so please don't use VNET_NAME() inside function
bodies, or anywhere else.  An accessor macro needs to resolve the
variable inside the curvnet, and VNET() is the macro which accomplishes
that, while VNET_NAME() doesn't.  The norm is to declare an abbreviated
accessor macro along the VNET_DEFINE() variable declaration, such as:

#define V_udp_require_l2_bcast VNET(udp_require_l2_bcast)

and then to use that accessor macro throught the rest of the code.

Marko



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