Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet Move the IPv4 multicast check earlier; we want t...



details:   https://anonhg.NetBSD.org/src/rev/0a73d6448344
branches:  trunk
changeset: 829695:0a73d6448344
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Feb 08 20:41:36 2018 +0000

description:
Move the IPv4 multicast check earlier; we want to kick multicast packets
all the time, and not just when they are SYNs.

The IPv6 multicast check is already done earlier, so this block of code
can be removed.

diffstat:

 sys/netinet/tcp_input.c |  23 ++++++-----------------
 1 files changed, 6 insertions(+), 17 deletions(-)

diffs (51 lines):

diff -r 04abfb01c382 -r 0a73d6448344 sys/netinet/tcp_input.c
--- a/sys/netinet/tcp_input.c   Thu Feb 08 20:19:30 2018 +0000
+++ b/sys/netinet/tcp_input.c   Thu Feb 08 20:41:36 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_input.c,v 1.372 2018/02/08 20:19:30 maxv Exp $     */
+/*     $NetBSD: tcp_input.c,v 1.373 2018/02/08 20:41:36 maxv Exp $     */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.372 2018/02/08 20:19:30 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.373 2018/02/08 20:41:36 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1294,6 +1294,10 @@
                af = AF_INET;
                iphlen = sizeof(struct ip);
 
+               if (IN_MULTICAST(ip->ip_dst.s_addr) ||
+                   in_broadcast(ip->ip_dst, m_get_rcvif_NOMPSAFE(m)))
+                       goto drop;
+
                /* We do the checksum after PCB lookup... */
                len = ntohs(ip->ip_len);
                tlen = len - toff;
@@ -1715,21 +1719,6 @@
                         * Received a SYN.
                         */
 
-                       switch (af) {
-#ifdef INET6
-                       case AF_INET6:
-                               if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_dst))
-                                       goto drop;
-                               break;
-#endif /* INET6 */
-                       case AF_INET:
-                               if (IN_MULTICAST(ip->ip_dst.s_addr) ||
-                                   in_broadcast(ip->ip_dst,
-                                                m_get_rcvif_NOMPSAFE(m)))
-                                       goto drop;
-                               break;
-                       }
-
 #ifdef INET6
                        /*
                         * If deprecated address is forbidden, we do



Home | Main Index | Thread Index | Old Index