]> err.no Git - linux-2.6/commitdiff
[HDLC] Fix dev->header_cache_update having a random value.
authorKrzysztof Halasa <khc@pm.waw.pl>
Fri, 2 Mar 2007 23:52:22 +0000 (15:52 -0800)
committerDavid S. Miller <davem@sunset.davemloft.net>
Sat, 3 Mar 2007 04:37:37 +0000 (20:37 -0800)
Switching HDLC devices from Ethernet-framing mode caused stale ethernet
function assignments within net_device.

Signed-off-by: Krzysztof Halasa <khc@pm.waw.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/wan/hdlc.c
drivers/net/wan/hdlc_cisco.c
drivers/net/wan/hdlc_fr.c
drivers/net/wan/hdlc_ppp.c
drivers/net/wan/hdlc_raw.c
drivers/net/wan/hdlc_x25.c

index 9040d7cf651e585d6b3976b76159ddef7125c7ee..65ad2e24caf071a5aa16a0a710a7b07c05c75aa3 100644 (file)
@@ -38,7 +38,7 @@
 #include <linux/hdlc.h>
 
 
-static const char* version = "HDLC support module revision 1.20";
+static const char* version = "HDLC support module revision 1.21";
 
 #undef DEBUG_LINK
 
@@ -222,19 +222,31 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        return -EINVAL;
 }
 
+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->hard_header         = NULL;
+       dev->rebuild_header      = NULL;
+       dev->set_mac_address     = NULL;
+       dev->hard_header_cache   = NULL;
+       dev->header_cache_update = NULL;
+       dev->change_mtu          = hdlc_change_mtu;
+       dev->hard_header_parse   = NULL;
+}
+
 static void hdlc_setup(struct net_device *dev)
 {
        hdlc_device *hdlc = dev_to_hdlc(dev);
 
-       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;
-
-       dev->flags = IFF_POINTOPOINT | IFF_NOARP;
-
+       hdlc_setup_dev(dev);
        hdlc->carrier = 1;
        hdlc->open = 0;
        spin_lock_init(&hdlc->state_lock);
@@ -294,6 +306,7 @@ void detach_hdlc_protocol(struct net_device *dev)
        }
        kfree(hdlc->state);
        hdlc->state = NULL;
+       hdlc_setup_dev(dev);
 }
 
 
index b0bc5ddcf1b11df483912a33160ce074c75ffa5c..c9664fd8a917eaf0889dedcd0b931db3e544a390 100644 (file)
@@ -365,10 +365,7 @@ static int cisco_ioctl(struct net_device *dev, struct ifreq *ifr)
                memcpy(&state(hdlc)->settings, &new_settings, size);
                dev->hard_start_xmit = hdlc->xmit;
                dev->hard_header = cisco_hard_header;
-               dev->hard_header_cache = NULL;
                dev->type = ARPHRD_CISCO;
-               dev->flags = IFF_POINTOPOINT | IFF_NOARP;
-               dev->addr_len = 0;
                netif_dormant_on(dev);
                return 0;
        }
index b45ab680d2d624b52c4b44f4d1d51cb4c268de5d..c6c3c757d6f13c850307a9e8d71316ce898631a5 100644 (file)
@@ -1289,10 +1289,7 @@ static int fr_ioctl(struct net_device *dev, struct ifreq *ifr)
                memcpy(&state(hdlc)->settings, &new_settings, size);
 
                dev->hard_start_xmit = hdlc->xmit;
-               dev->hard_header = NULL;
                dev->type = ARPHRD_FRAD;
-               dev->flags = IFF_POINTOPOINT | IFF_NOARP;
-               dev->addr_len = 0;
                return 0;
 
        case IF_PROTO_FR_ADD_PVC:
index e9f717070fde0d58bc4f1c103472510c7f9b9fff..4591437dd2f3dca75470b5d259bdaed8f1d65c5e 100644 (file)
@@ -127,9 +127,7 @@ static int ppp_ioctl(struct net_device *dev, struct ifreq *ifr)
                if (result)
                        return result;
                dev->hard_start_xmit = hdlc->xmit;
-               dev->hard_header = NULL;
                dev->type = ARPHRD_PPP;
-               dev->addr_len = 0;
                netif_dormant_off(dev);
                return 0;
        }
index fe3cae5c6b9d07a267fde91d3051c950ea11e906..e23bc6656267401270488809d0a73d886203adb8 100644 (file)
@@ -88,10 +88,7 @@ static int raw_ioctl(struct net_device *dev, struct ifreq *ifr)
                        return result;
                memcpy(hdlc->state, &new_settings, size);
                dev->hard_start_xmit = hdlc->xmit;
-               dev->hard_header = NULL;
                dev->type = ARPHRD_RAWHDLC;
-               dev->flags = IFF_POINTOPOINT | IFF_NOARP;
-               dev->addr_len = 0;
                netif_dormant_off(dev);
                return 0;
        }
index e4bb9f8ad4337e1cb34bb7b9835732119877c3b3..cd7b22f50edc562d9fa9f35bf809656fc834227b 100644 (file)
@@ -215,9 +215,7 @@ static int x25_ioctl(struct net_device *dev, struct ifreq *ifr)
                                                   x25_rx, 0)) != 0)
                        return result;
                dev->hard_start_xmit = x25_xmit;
-               dev->hard_header = NULL;
                dev->type = ARPHRD_X25;
-               dev->addr_len = 0;
                netif_dormant_off(dev);
                return 0;
        }