From: Mark Huang Date: Tue, 1 Feb 2005 03:19:52 +0000 (+0000) Subject: - bound vnet mods by #ifdef X-Git-Tag: before-fedora-2_6_18-1_2239_FC5-vs2_0_2_2-rc6-merge~271 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=d2405f1b97faa686762112783ced16278774237b;p=linux-2.6.git - bound vnet mods by #ifdef - bound runtime vnet code by if (vnet_active) --- diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 104457202..40643a19d 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -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); } diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 0b5d21ef1..ad9d5ac77 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -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