Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet PR/52074: Frank Kardel: current npf map directiv...



details:   https://anonhg.NetBSD.org/src/rev/c4244f49a1e6
branches:  trunk
changeset: 823761:c4244f49a1e6
user:      christos <christos%NetBSD.org@localhost>
date:      Sun May 07 16:41:22 2017 +0000

description:
PR/52074: Frank Kardel: current npf map directive broken
Don't filter packets that can't be resolved to source interfaces because
they could have been generated by a packet filter.

diffstat:

 sys/netinet/ip_output.c |  18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diffs (50 lines):

diff -r a16eeb311a2a -r c4244f49a1e6 sys/netinet/ip_output.c
--- a/sys/netinet/ip_output.c   Sun May 07 15:01:18 2017 +0000
+++ b/sys/netinet/ip_output.c   Sun May 07 16:41:22 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_output.c,v 1.276 2017/03/05 11:07:46 ozaki-r Exp $  */
+/*     $NetBSD: ip_output.c,v 1.277 2017/05/07 16:41:22 christos Exp $ */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.276 2017/03/05 11:07:46 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.277 2017/05/07 16:41:22 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -611,13 +611,18 @@
 
        /*
         * search for the source address structure to
-        * maintain output statistics.
+        * maintain output statistics, and verify address
+        * validity
         */
        KASSERT(ia == NULL);
        ia = in_get_ia_psref(ip->ip_src, &psref_ia);
 
-       /* Ensure we only send from a valid address. */
-       if ((ia != NULL || (flags & IP_FORWARDING) == 0) &&
+       /*
+        * Ensure we only send from a valid address.
+        * A NULL address is valid because the packet could be
+        * generated from a packet filter.
+        */
+       if (ia != NULL && (flags & IP_FORWARDING) == 0 &&
            (error = ip_ifaddrvalid(ia)) != 0)
        {
                ARPLOG(LOG_ERR,
@@ -1940,9 +1945,6 @@
 ip_ifaddrvalid(const struct in_ifaddr *ia)
 {
 
-       if (ia == NULL)
-               return -1;
-
        if (ia->ia_addr.sin_addr.s_addr == INADDR_ANY)
                return 0;
 



Home | Main Index | Thread Index | Old Index