]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/llc/llc_input.c
[NET]: Make packet reception network namespace safe
[linux-2.6-omap-h63xx.git] / net / llc / llc_input.c
index 94d2368ade92c6368eec7121e26b2dbea4e04a65..c40c9b2a345aca6058d222ad662f4a830c943d7e 100644 (file)
@@ -12,6 +12,7 @@
  * See the GNU General Public License for more details.
  */
 #include <linux/netdevice.h>
+#include <net/net_namespace.h>
 #include <net/llc.h>
 #include <net/llc_pdu.h>
 #include <net/llc_sap.h>
@@ -112,11 +113,11 @@ static inline int llc_fixup_skb(struct sk_buff *skb)
        if (unlikely(!pskb_may_pull(skb, llc_len)))
                return 0;
 
-       skb->h.raw += llc_len;
+       skb->transport_header += llc_len;
        skb_pull(skb, llc_len);
        if (skb->protocol == htons(ETH_P_802_2)) {
-               u16 pdulen = eth_hdr(skb)->h_proto,
-                   data_size = ntohs(pdulen) - llc_len;
+               __be16 pdulen = eth_hdr(skb)->h_proto;
+               u16 data_size = ntohs(pdulen) - llc_len;
 
                if (unlikely(pskb_trim_rcsum(skb, data_size)))
                        return 0;
@@ -145,6 +146,9 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev,
        int (*rcv)(struct sk_buff *, struct net_device *,
                   struct packet_type *, struct net_device *);
 
+       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.
@@ -164,7 +168,7 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev,
        sap = llc_sap_find(pdu->dsap);
        if (unlikely(!sap)) {/* unknown SAP */
                dprintk("%s: llc_sap_find(%02X) failed!\n", __FUNCTION__,
-                       pdu->dsap);
+                       pdu->dsap);
                goto drop;
        }
        /*
@@ -173,9 +177,9 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev,
         */
        rcv = rcu_dereference(sap->rcv_func);
        if (rcv) {
-               struct sk_buff *cskb = skb_clone(skb, GFP_ATOMIC);
-               if (cskb)
-                       rcv(cskb, dev, pt, orig_dev);
+               struct sk_buff *cskb = skb_clone(skb, GFP_ATOMIC);
+               if (cskb)
+                       rcv(cskb, dev, pt, orig_dev);
        }
        dest = llc_pdu_type(skb);
        if (unlikely(!dest || !llc_type_handlers[dest - 1]))