]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/wan/hdlc.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[linux-2.6-omap-h63xx.git] / drivers / net / wan / hdlc.c
index db354e0edbe57692185e1d6fecae60f7d5cfbbaa..d553e6f328513a56f633bf35d2e562c5d979f08f 100644 (file)
 #include <linux/rtnetlink.h>
 #include <linux/notifier.h>
 #include <linux/hdlc.h>
+#include <net/net_namespace.h>
 
 
-static const char* version = "HDLC support module revision 1.20";
+static const char* version = "HDLC support module revision 1.21";
 
 #undef DEBUG_LINK
 
@@ -66,6 +67,12 @@ static int hdlc_rcv(struct sk_buff *skb, struct net_device *dev,
                    struct packet_type *p, struct net_device *orig_dev)
 {
        struct hdlc_device_desc *desc = dev_to_desc(dev);
+
+       if (dev->nd_net != &init_net) {
+               kfree_skb(skb);
+               return 0;
+       }
+
        if (desc->netif_rx)
                return desc->netif_rx(skb);
 
@@ -102,6 +109,9 @@ static int hdlc_device_event(struct notifier_block *this, unsigned long event,
        unsigned long flags;
        int on;
  
+       if (dev->nd_net != &init_net)
+               return NOTIFY_DONE;
+
        if (dev->get_stats != hdlc_get_stats)
                return NOTIFY_DONE; /* not an HDLC device */
  
@@ -222,19 +232,29 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        return -EINVAL;
 }
 
-void hdlc_setup(struct net_device *dev)
-{
-       hdlc_device *hdlc = dev_to_hdlc(dev);
+static const struct header_ops hdlc_null_ops;
 
-       dev->get_stats = hdlc_get_stats;
-       dev->change_mtu = hdlc_change_mtu;
-       dev->mtu = HDLC_MAX_MTU;
-
-       dev->type = ARPHRD_RAWHDLC;
-       dev->hard_header_len = 16;
+static void hdlc_setup_dev(struct net_device *dev)
+{
+       /* Re-init all variables changed by HDLC protocol drivers,
+        * including ether_setup() called from hdlc_raw_eth.c.
+        */
+       dev->get_stats           = hdlc_get_stats;
+       dev->flags               = IFF_POINTOPOINT | IFF_NOARP;
+       dev->mtu                 = HDLC_MAX_MTU;
+       dev->type                = ARPHRD_RAWHDLC;
+       dev->hard_header_len     = 16;
+       dev->addr_len            = 0;
+       dev->header_ops          = &hdlc_null_ops;
+
+       dev->change_mtu          = hdlc_change_mtu;
+}
 
-       dev->flags = IFF_POINTOPOINT | IFF_NOARP;
+static void hdlc_setup(struct net_device *dev)
+{
+       hdlc_device *hdlc = dev_to_hdlc(dev);
 
+       hdlc_setup_dev(dev);
        hdlc->carrier = 1;
        hdlc->open = 0;
        spin_lock_init(&hdlc->state_lock);
@@ -294,6 +314,7 @@ void detach_hdlc_protocol(struct net_device *dev)
        }
        kfree(hdlc->state);
        hdlc->state = NULL;
+       hdlc_setup_dev(dev);
 }
 
 
@@ -325,7 +346,6 @@ MODULE_LICENSE("GPL v2");
 EXPORT_SYMBOL(hdlc_open);
 EXPORT_SYMBOL(hdlc_close);
 EXPORT_SYMBOL(hdlc_ioctl);
-EXPORT_SYMBOL(hdlc_setup);
 EXPORT_SYMBOL(alloc_hdlcdev);
 EXPORT_SYMBOL(unregister_hdlc_device);
 EXPORT_SYMBOL(register_hdlc_protocol);