svn commit: r300679 - head/sys/netinet

Michael Tuexen tuexen at freebsd.org
Fri May 27 09:13:25 UTC 2016


> On 26 May 2016, at 23:33, Gleb Smirnoff <glebius at FreeBSD.org> wrote:
> 
>  Michael,
> 
> On Wed, May 25, 2016 at 01:48:26PM +0000, Michael Tuexen wrote:
> M> Author: tuexen
> M> Date: Wed May 25 13:48:26 2016
> M> New Revision: 300679
> M> URL: https://svnweb.freebsd.org/changeset/base/300679
> M> 
> M> Log:
> M>   Count packets as not being delivered only if they are neither
> M>   processed by a kernel handler nor by a raw socket.
> M>   
> M>   MFC after:	1 week
> M> 
> M> Modified:
> M>   head/sys/netinet/raw_ip.c
> M> 
> M> Modified: head/sys/netinet/raw_ip.c
> M> ==============================================================================
> M> --- head/sys/netinet/raw_ip.c	Wed May 25 13:09:06 2016	(r300678)
> M> +++ head/sys/netinet/raw_ip.c	Wed May 25 13:48:26 2016	(r300679)
> M> @@ -132,6 +132,8 @@ int (*ip_rsvp_vif)(struct socket *, stru
> M>  void (*ip_rsvp_force_done)(struct socket *);
> M>  #endif /* INET */
> M>  
> M> +extern	struct protosw inetsw[];
> M> +
> M>  u_long	rip_sendspace = 9216;
> M>  SYSCTL_ULONG(_net_inet_raw, OID_AUTO, maxdgram, CTLFLAG_RW,
> M>      &rip_sendspace, 0, "Maximum outgoing raw IP datagram size");
> M> @@ -411,9 +413,11 @@ rip_input(struct mbuf **mp, int *offp, i
> M>  			IPSTAT_INC(ips_delivered);
> M>  		INP_RUNLOCK(last);
> M>  	} else {
> M> +		if (inetsw[ip_protox[ip->ip_p]].pr_input == rip_input) {
> M> +			IPSTAT_INC(ips_noproto);
> M> +			IPSTAT_DEC(ips_delivered);
> M> +		}
> M>  		m_freem(m);
> M> -		IPSTAT_INC(ips_noproto);
> M> -		IPSTAT_DEC(ips_delivered);
> M>  	}
> M>  	return (IPPROTO_DONE);
> M>  }
> 
> How could it happen at this place that inetsw[ip_protox[ip->ip_p]].pr_input != rip_input?
Hi Gleb,

rip_input() does not only get called when there is no protocol handler in the kernel
for the protocol, but also, for example, for ICMP. See
http://svnweb.freebsd.org/base/head/sys/netinet/ip_icmp.c?revision=300699&view=markup#l684
I think we should only increment the ips_noproto counter when we neither have a handler for
it in the kernel nor any raw socket. That is why I added the condition. Did I miss anything?
> 
> Another question. Can we get rid of ugly IPSTAT_DEC()? Since pr_input is an integer,
> we could return error up to ip_input() that would indicate non-delivery.
I think the return code indicates whether the packet processing is done or not, not
to return an error.

Best regards
Michael
> 
> -- 
> Totus tuus, Glebius.



More information about the svn-src-head mailing list