]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/net/hamradio/bpqether.c
[NET]: Wrap netdevice hardware header creation.
[net-next-2.6.git] / drivers / net / hamradio / bpqether.c
index cc0ee93669eac11c4c4cad1d99c611889c866da4..4bff23e3b970c71bf4e8f840aa22861b76e5ca27 100644 (file)
@@ -64,7 +64,7 @@
 #include <net/ax25.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
-#include <linux/if_ether.h>
+#include <linux/etherdevice.h>
 #include <linux/if_arp.h>
 #include <linux/skbuff.h>
 #include <net/sock.h>
@@ -83,6 +83,7 @@
 
 #include <net/ip.h>
 #include <net/arp.h>
+#include <net/net_namespace.h>
 
 #include <linux/bpqether.h>
 
@@ -94,7 +95,6 @@ static char bpq_eth_addr[6];
 
 static int bpq_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *);
 static int bpq_device_event(struct notifier_block *, unsigned long, void *);
-static const char *bpq_print_ethaddr(const unsigned char *);
 
 static struct packet_type bpq_packet_type = {
        .type   = __constant_htons(ETH_P_BPQ),
@@ -172,6 +172,9 @@ static int bpq_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_ty
        struct ethhdr *eth;
        struct bpqdev *bpq;
 
+       if (dev->nd_net != &init_net)
+               goto drop;
+
        if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL)
                return NET_RX_DROP;
 
@@ -283,7 +286,7 @@ static int bpq_xmit(struct sk_buff *skb, struct net_device *dev)
 
        skb->protocol = ax25_type_trans(skb, dev);
        skb_reset_network_header(skb);
-       dev->hard_header(skb, dev, ETH_P_BPQ, bpq->dest_addr, NULL, 0);
+       dev_hard_header(skb, dev, ETH_P_BPQ, bpq->dest_addr, NULL, 0);
        bpq->stats.tx_packets++;
        bpq->stats.tx_bytes+=skb->len;
   
@@ -379,16 +382,6 @@ static int bpq_close(struct net_device *dev)
 /*
  *     Proc filesystem
  */
-static const char * bpq_print_ethaddr(const unsigned char *e)
-{
-       static char buf[18];
-
-       sprintf(buf, "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
-               e[0], e[1], e[2], e[3], e[4], e[5]);
-
-       return buf;
-}
-
 static void *bpq_seq_start(struct seq_file *seq, loff_t *pos)
 {
        int i = 1;
@@ -434,14 +427,16 @@ static int bpq_seq_show(struct seq_file *seq, void *v)
                         "dev   ether      destination        accept from\n");
        else {
                const struct bpqdev *bpqdev = v;
+               DECLARE_MAC_BUF(mac);
 
                seq_printf(seq, "%-5s %-10s %s  ",
                        bpqdev->axdev->name, bpqdev->ethdev->name,
-                       bpq_print_ethaddr(bpqdev->dest_addr));
+                       print_mac(mac, bpqdev->dest_addr));
 
-               seq_printf(seq, "%s\n",
-                       (bpqdev->acpt_addr[0] & 0x01) ? "*" 
-                          : bpq_print_ethaddr(bpqdev->acpt_addr));
+               if (is_multicast_ether_addr(bpqdev->acpt_addr))
+                       seq_printf(seq, "*\n");
+               else
+                       seq_printf(seq, "%s\n", print_mac(mac, bpqdev->acpt_addr));
 
        }
        return 0;
@@ -559,6 +554,9 @@ static int bpq_device_event(struct notifier_block *this,unsigned long event, voi
 {
        struct net_device *dev = (struct net_device *)ptr;
 
+       if (dev->nd_net != &init_net)
+               return NOTIFY_DONE;
+
        if (!dev_is_ethdev(dev))
                return NOTIFY_DONE;
 
@@ -594,7 +592,7 @@ static int bpq_device_event(struct notifier_block *this,unsigned long event, voi
 static int __init bpq_init_driver(void)
 {
 #ifdef CONFIG_PROC_FS
-       if (!proc_net_fops_create("bpqether", S_IRUGO, &bpq_info_fops)) {
+       if (!proc_net_fops_create(&init_net, "bpqether", S_IRUGO, &bpq_info_fops)) {
                printk(KERN_ERR
                        "bpq: cannot create /proc/net/bpqether entry.\n");
                return -ENOENT;
@@ -618,7 +616,7 @@ static void __exit bpq_cleanup_driver(void)
 
        unregister_netdevice_notifier(&bpq_dev_notifier);
 
-       proc_net_remove("bpqether");
+       proc_net_remove(&init_net, "bpqether");
 
        rtnl_lock();
        while (!list_empty(&bpq_devices)) {