<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">*** tcp_input.c.orig    Fri Jan 21 09:04:37 2000
--- tcp_input.c Sat Jan 22 03:40:05 2000
***************
*** 381,386 ****
--- 381,387 ----
        struct tcpopt to;               /* options in this segment */
        struct rmxp_tao *taop;          /* pointer to our TAO cache entry */
        struct rmxp_tao tao_noncached;  /* in case there's no cached entry */
+       int wildcard = 0;
  #ifdef TCPDEBUG
        short ostate = 0;
  #endif
***************
*** 511,518 ****
        drop_hdrlen = off0 + off;
  
        /*
!       * Locate pcb for segment.
        */
  findpcb:
  #ifdef IPFIREWALL_FORWARD
        if (ip_fw_fwd_addr != NULL
--- 512,528 ----
        drop_hdrlen = off0 + off;
  
        /*
!       * Locate pcb for segment.  If this is not a SYN segment, don't
!       * bother searching for the pcb of a listening socket with a
!       * wildcard address.
!       *
!       * Checking TH_RST isn't strictly necessary here, but it doesn't
!       * cost anything, saves a hash lookup, takes a shorter path to
!       * dropwithreset (which will drop the packet), and allows a test
!       * to be removed from the TCPS_LISTEN case.
        */
+       if ((thflags &amp; (TH_ACK|TH_SYN|TH_RST)) == TH_SYN)
+               wildcard = 1;
  findpcb:
  #ifdef IPFIREWALL_FORWARD
        if (ip_fw_fwd_addr != NULL
***************
*** 533,544 ****
                        if (!ip_fw_fwd_addr-&gt;sin_port) {
                                inp = in_pcblookup_hash(&amp;tcbinfo, ip-&gt;ip_src,
                                    th-&gt;th_sport, ip_fw_fwd_addr-&gt;sin_addr,
!                                   th-&gt;th_dport, 1, m-&gt;m_pkthdr.rcvif);
                        } else {
                                inp = in_pcblookup_hash(&amp;tcbinfo,
                                    ip-&gt;ip_src, th-&gt;th_sport,
                                    ip_fw_fwd_addr-&gt;sin_addr,
!                                   ntohs(ip_fw_fwd_addr-&gt;sin_port), 1,
                                    m-&gt;m_pkthdr.rcvif);
                        }
                }
--- 543,554 ----
                        if (!ip_fw_fwd_addr-&gt;sin_port) {
                                inp = in_pcblookup_hash(&amp;tcbinfo, ip-&gt;ip_src,
                                    th-&gt;th_sport, ip_fw_fwd_addr-&gt;sin_addr,
!                                   th-&gt;th_dport, wildcard, m-&gt;m_pkthdr.rcvif);
                        } else {
                                inp = in_pcblookup_hash(&amp;tcbinfo,
                                    ip-&gt;ip_src, th-&gt;th_sport,
                                    ip_fw_fwd_addr-&gt;sin_addr,
!                                   ntohs(ip_fw_fwd_addr-&gt;sin_port), wildcard,
                                    m-&gt;m_pkthdr.rcvif);
                        }
                }
***************
*** 549,560 ****
  #ifdef INET6
        if (isipv6)
                inp = in6_pcblookup_hash(&amp;tcbinfo, &amp;ip6-&gt;ip6_src, th-&gt;th_sport,
!                                       &amp;ip6-&gt;ip6_dst, th-&gt;th_dport, 1,
                                        m-&gt;m_pkthdr.rcvif);
        else
  #endif /* INET6 */
        inp = in_pcblookup_hash(&amp;tcbinfo, ip-&gt;ip_src, th-&gt;th_sport,
!           ip-&gt;ip_dst, th-&gt;th_dport, 1, m-&gt;m_pkthdr.rcvif);
        }
  
  #ifdef IPSEC
--- 559,570 ----
  #ifdef INET6
        if (isipv6)
                inp = in6_pcblookup_hash(&amp;tcbinfo, &amp;ip6-&gt;ip6_src, th-&gt;th_sport,
!                                       &amp;ip6-&gt;ip6_dst, th-&gt;th_dport, wildcard,
                                        m-&gt;m_pkthdr.rcvif);
        else
  #endif /* INET6 */
        inp = in_pcblookup_hash(&amp;tcbinfo, ip-&gt;ip_src, th-&gt;th_sport,
!           ip-&gt;ip_dst, th-&gt;th_dport, wildcard, m-&gt;m_pkthdr.rcvif);
        }
  
  #ifdef IPSEC
***************
*** 615,624 ****
                                break;
                        }
                }
- #ifdef ICMP_BANDLIM
-               if (badport_bandlim(1) &lt; 0)
-                       goto drop;
- #endif
                if (blackhole) { 
                        switch (blackhole) {
                        case 1:
--- 625,630 ----
***************
*** 996,1001 ****
--- 1002,1013 ----
                register struct sockaddr_in6 *sin6;
  #endif
  
+               /*
+               * XXX - the following three tests should no longer be
+               * necessary because of the "wildcard" test added
+               * above.  These should probably be changed to assertions
+               * until the code is thoroughly shaked out.
+               */
                if (thflags &amp; TH_RST)
                        goto drop;
                if (thflags &amp; TH_ACK)
***************
*** 1017,1032 ****
                * RFC1122 4.2.3.10, p. 104: discard bcast/mcast SYN
                * in_broadcast() should never return true on a received
                * packet with M_BCAST not set.
                */
                if (m-&gt;m_flags &amp; (M_BCAST|M_MCAST))
                        goto drop;
  #ifdef INET6
                if (isipv6) {
!                       if (IN6_IS_ADDR_MULTICAST(&amp;ip6-&gt;ip6_dst))
                                goto drop;
                } else
  #endif
!               if (IN_MULTICAST(ntohl(ip-&gt;ip_dst.s_addr)))
                        goto drop;
  #ifdef INET6
                if (isipv6) {
--- 1029,1050 ----
                * RFC1122 4.2.3.10, p. 104: discard bcast/mcast SYN
                * in_broadcast() should never return true on a received
                * packet with M_BCAST not set.
+               *
+               * Packets with a multicast source address should also
+               * be discarded.
                */
                if (m-&gt;m_flags &amp; (M_BCAST|M_MCAST))
                        goto drop;
  #ifdef INET6
                if (isipv6) {
!                       if (IN6_IS_ADDR_MULTICAST(&amp;ip6-&gt;ip6_dst) ||
!                           IN6_IS_ADDR_MULTICAST(&amp;ip6-&gt;ip6_src))
                                goto drop;
                } else
  #endif
!               if (IN_MULTICAST(ntohl(ip-&gt;ip_dst.s_addr)) ||
!                   IN_MULTICAST(ntohl(ip-&gt;ip_src.s_addr)) ||
!                   IN_EXPERIMENTAL(ntohl(ip-&gt;ip_src.s_addr)))
                        goto drop;
  #ifdef INET6
                if (isipv6) {
***************
*** 2217,2229 ****
                goto drop;
  #ifdef INET6
        if (isipv6) {
!               if (IN6_IS_ADDR_MULTICAST(&amp;ip6-&gt;ip6_dst))
                        goto drop;
        } else
  #endif /* INET6 */
!       if (IN_MULTICAST(ntohl(ip-&gt;ip_dst.s_addr)))
                goto drop;
        /* IPv6 anycast check is done at tcp6_input() */
  #ifdef TCPDEBUG
        if (tp == 0 || (tp-&gt;t_inpcb-&gt;inp_socket-&gt;so_options &amp; SO_DEBUG))
                tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen,
--- 2235,2254 ----
                goto drop;
  #ifdef INET6
        if (isipv6) {
!               if (IN6_IS_ADDR_MULTICAST(&amp;ip6-&gt;ip6_dst) ||
!                   IN6_IS_ADDR_MULTICAST(&amp;ip6-&gt;ip6_src))
                        goto drop;
        } else
  #endif /* INET6 */
!       if (IN_MULTICAST(ntohl(ip-&gt;ip_dst.s_addr)) ||
!           IN_MULTICAST(ntohl(ip-&gt;ip_src.s_addr)) ||
!           IN_EXPERIMENTAL(ntohl(ip-&gt;ip_src.s_addr)))
                goto drop;
        /* IPv6 anycast check is done at tcp6_input() */
+ #ifdef ICMP_BANDLIM
+       if (badport_bandlim(1) &lt; 0)
+               goto drop;
+ #endif
  #ifdef TCPDEBUG
        if (tp == 0 || (tp-&gt;t_inpcb-&gt;inp_socket-&gt;so_options &amp; SO_DEBUG))
                tcp_trace(TA_DROP, ostate, tp, (void *)tcp_saveipgen,


</pre></body></html>