netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, devel@openvz.org,
	containers@lists.osdl.org, xemul@openvz.org,
	"Denis V. Lunev" <den@openvz.org>
Subject: [PATCH 9/11 net-2.6.26] [NETNS]: Drop packets in the non-initial namespace on the per/protocol basis.
Date: Mon, 24 Mar 2008 17:36:10 +0300	[thread overview]
Message-ID: <1206369372-27711-9-git-send-email-den@openvz.org> (raw)
In-Reply-To: <1206369185.23705.7.camel@iris.sw.ru>

IP layer now can handle multiple namespaces normally. So, process such
packets normally and drop them only if the transport layer is not aware about
namespaces.

Signed-off-by: Denis V. Lunev <den@openvz.org>
---
 include/net/protocol.h |    3 ++-
 net/ipv4/ip_input.c    |    8 ++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/net/protocol.h b/include/net/protocol.h
index ad8c584..8d024d7 100644
--- a/include/net/protocol.h
+++ b/include/net/protocol.h
@@ -39,7 +39,8 @@ struct net_protocol {
 	int			(*gso_send_check)(struct sk_buff *skb);
 	struct sk_buff	       *(*gso_segment)(struct sk_buff *skb,
 					       int features);
-	int			no_policy;
+	unsigned int		no_policy:1,
+				netns_ok:1;
 };
 
 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index eb1fa27..2aeea5d 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -199,6 +199,8 @@ int ip_call_ra_chain(struct sk_buff *skb)
 
 static int ip_local_deliver_finish(struct sk_buff *skb)
 {
+	struct net *net = skb->dev->nd_net;
+
 	__skb_pull(skb, ip_hdrlen(skb));
 
 	/* Point into the IP datagram, just past the header. */
@@ -214,7 +216,8 @@ static int ip_local_deliver_finish(struct sk_buff *skb)
 		raw = raw_local_deliver(skb, protocol);
 
 		hash = protocol & (MAX_INET_PROTOS - 1);
-		if ((ipprot = rcu_dereference(inet_protos[hash])) != NULL) {
+		ipprot = rcu_dereference(inet_protos[hash]);
+		if (ipprot != NULL && (net == &init_net || ipprot->netns_ok)) {
 			int ret;
 
 			if (!ipprot->no_policy) {
@@ -375,9 +378,6 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
 	struct iphdr *iph;
 	u32 len;
 
-	if (dev->nd_net != &init_net)
-		goto drop;
-
 	/* When the interface is in promisc. mode, drop all the crap
 	 * that it receives, do not try to analyse it.
 	 */
-- 
1.5.3.rc5


  parent reply	other threads:[~2008-03-24 14:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-24 14:33 [PATCH 0/11 net-2.6.26] UDP/ICMP/TCP for a namespace Denis V. Lunev
2008-03-24 14:36 ` [PATCH 1/11 2.6.26] [NETNS]: Process ARP in the context of the correct namespace Denis V. Lunev
2008-03-24 14:36 ` [PATCH 2/11 net-2.6.26] [NETNS]: /proc/net/arp namespacing Denis V. Lunev
2008-03-24 14:36 ` [PATCH 3/11 net-2.6.26] [NETNS]: Add namespace parameter to ip_options_compile Denis V. Lunev
2008-03-24 14:36 ` [PATCH 4/11 net-2.6.25] [NETNS]: Add namespace parameter to ip_options_get(...) Denis V. Lunev
2008-03-24 14:36 ` [PATCH 5/11 net-2.6.26] [NETNS]: Add namespace parameter to ip_cmsg_send Denis V. Lunev
2008-03-24 14:36 ` [PATCH 6/11 net-2.6.26] [NETNS]: Process IP layer in the context of the correct namespace Denis V. Lunev
2008-03-24 14:36 ` [PATCH 7/11 net-2.6.26] [NETNS]: Process INET socket layer in " Denis V. Lunev
2008-03-24 14:36 ` [PATCH 8/11 net-2.6.26] [NETNS]: Process netfilter hooks in initial namespace only Denis V. Lunev
2008-03-24 14:36 ` Denis V. Lunev [this message]
2008-03-24 14:36 ` [PATCH 10/11 net-2.6.26] [NETNS]: Allow to create sockets in non-initial namespace Denis V. Lunev
2008-03-24 14:36 ` [PATCH 11/11 net-2.6.25] [NETNS]: Enable TCP/UDP/ICMP inside namespace Denis V. Lunev
2008-03-24 22:44 ` [PATCH 0/11 net-2.6.26] UDP/ICMP/TCP for a namespace David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1206369372-27711-9-git-send-email-den@openvz.org \
    --to=den@openvz.org \
    --cc=containers@lists.osdl.org \
    --cc=davem@davemloft.net \
    --cc=devel@openvz.org \
    --cc=netdev@vger.kernel.org \
    --cc=xemul@openvz.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).