- bound vnet mods by #ifdef
authorMark Huang <mlhuang@cs.princeton.edu>
Tue, 1 Feb 2005 03:19:52 +0000 (03:19 +0000)
committerMark Huang <mlhuang@cs.princeton.edu>
Tue, 1 Feb 2005 03:19:52 +0000 (03:19 +0000)
- bound runtime vnet code by if (vnet_active)

net/ipv4/tcp_ipv4.c
net/ipv4/udp.c

index 1044572..40643a1 100644 (file)
@@ -1758,10 +1758,6 @@ csum_err:
        goto discard;
 }
 
-extern struct proto_ops inet_stream_ops;
-
-extern int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len);
-
 /*
  *     From tcp_input.c
  */
@@ -1813,13 +1809,14 @@ int tcp_v4_rcv(struct sk_buff *skb)
                goto no_tcp_socket;
 
 process:
-       /* Silently drop if VNET is active (if INET bind() has been
-        * overridden) and the context is not entitled to read the
-        * packet.
+#if defined(CONFIG_VNET) || defined(CONFIG_VNET_MODULE)
+       /* Silently drop if VNET is active and the context is not
+        * entitled to read the packet.
         */
-       if (inet_stream_ops.bind != inet_bind &&
+       if (vnet_active &&
            (int) sk->sk_xid > 0 && sk->sk_xid != skb->xid)
                goto discard_it;
+#endif
 
        if (sk->sk_state == TCP_TIME_WAIT)
                goto do_time_wait;
@@ -1852,8 +1849,11 @@ no_tcp_socket:
        if (skb->len < (th->doff << 2) || tcp_checksum_complete(skb)) {
 bad_packet:
                TCP_INC_STATS_BH(TCP_MIB_INERRS);
-       } else if (!skb->sk) {
+#if defined(CONFIG_VNET) || defined(CONFIG_VNET_MODULE)
+       } else if (vnet_active && skb->sk) {
                /* VNET: Suppress RST if the port was bound to a (presumably raw) socket */
+#endif
+       } else {
                tcp_v4_send_reset(skb);
        }
 
index 0b5d21e..ad9d5ac 100644 (file)
@@ -1236,11 +1236,16 @@ int udp_rcv(struct sk_buff *skb)
        if (udp_checksum_complete(skb))
                goto csum_error;
 
-       /* VNET: Suppress ICMP Unreachable if the port was bound to a (presumably raw) socket */
-       if (!skb->sk) {
-               UDP_INC_STATS_BH(UDP_MIB_NOPORTS);
-               icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
+#if defined(CONFIG_VNET) || defined(CONFIG_VNET_MODULE)
+       if (vnet_active && skb->sk) {
+               /* VNET: Suppress ICMP Unreachable if the port was bound to a (presumably raw) socket */
+               kfree_skb(skb);
+               return 0;
        }
+#endif
+
+       UDP_INC_STATS_BH(UDP_MIB_NOPORTS);
+       icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
 
        /*
         * Hmm.  We got an UDP packet to a port to which we