Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / drivers / net / wan / hdlc_cisco.c
index 43e8bf3..1fd0466 100644 (file)
@@ -72,7 +72,7 @@ static void cisco_keepalive_send(struct net_device *dev, u32 type,
        }
        skb_reserve(skb, 4);
        cisco_hard_header(skb, dev, CISCO_KEEPALIVE, NULL, NULL, 0);
-       data = (cisco_packet*)skb->tail;
+       data = (cisco_packet*)(skb->data + 4);
 
        data->type = htonl(type);
        data->par1 = htonl(par1);
@@ -91,8 +91,7 @@ static void cisco_keepalive_send(struct net_device *dev, u32 type,
 
 
 
-static unsigned short cisco_type_trans(struct sk_buff *skb,
-                                      struct net_device *dev)
+static __be16 cisco_type_trans(struct sk_buff *skb, struct net_device *dev)
 {
        hdlc_header *data = (hdlc_header*)skb->data;
 
@@ -180,7 +179,8 @@ static int cisco_rx(struct sk_buff *skb)
 
                case CISCO_KEEPALIVE_REQ:
                        hdlc->state.cisco.rxseq = ntohl(cisco_data->par1);
-                       if (ntohl(cisco_data->par2)==hdlc->state.cisco.txseq) {
+                       if (hdlc->state.cisco.request_sent &&
+                           ntohl(cisco_data->par2)==hdlc->state.cisco.txseq) {
                                hdlc->state.cisco.last_poll = jiffies;
                                if (!hdlc->state.cisco.up) {
                                        u32 sec, min, hrs, days;
@@ -192,8 +192,11 @@ static int cisco_rx(struct sk_buff *skb)
                                               "uptime %ud%uh%um%us)\n",
                                               dev->name, days, hrs,
                                               min, sec);
+#if 0
+                                       netif_carrier_on(dev);
+#endif
+                                       hdlc->state.cisco.up = 1;
                                }
-                               hdlc->state.cisco.up = 1;
                        }
 
                        dev_kfree_skb_any(skb);
@@ -219,17 +222,20 @@ static void cisco_timer(unsigned long arg)
        struct net_device *dev = (struct net_device *)arg;
        hdlc_device *hdlc = dev_to_hdlc(dev);
 
-       if (hdlc->state.cisco.up && jiffies - hdlc->state.cisco.last_poll >=
-           hdlc->state.cisco.settings.timeout * HZ) {
+       if (hdlc->state.cisco.up &&
+           time_after(jiffies, hdlc->state.cisco.last_poll +
+                      hdlc->state.cisco.settings.timeout * HZ)) {
                hdlc->state.cisco.up = 0;
                printk(KERN_INFO "%s: Link down\n", dev->name);
-               if (netif_carrier_ok(dev))
-                       netif_carrier_off(dev);
+#if 0
+               netif_carrier_off(dev);
+#endif
        }
 
        cisco_keepalive_send(dev, CISCO_KEEPALIVE_REQ,
                             ++hdlc->state.cisco.txseq,
                             hdlc->state.cisco.rxseq);
+       hdlc->state.cisco.request_sent = 1;
        hdlc->state.cisco.timer.expires = jiffies +
                hdlc->state.cisco.settings.interval * HZ;
        hdlc->state.cisco.timer.function = cisco_timer;
@@ -242,8 +248,8 @@ static void cisco_timer(unsigned long arg)
 static void cisco_start(struct net_device *dev)
 {
        hdlc_device *hdlc = dev_to_hdlc(dev);
-       hdlc->state.cisco.last_poll = 0;
        hdlc->state.cisco.up = 0;
+       hdlc->state.cisco.request_sent = 0;
        hdlc->state.cisco.txseq = hdlc->state.cisco.rxseq = 0;
 
        init_timer(&hdlc->state.cisco.timer);
@@ -257,16 +263,21 @@ static void cisco_start(struct net_device *dev)
 
 static void cisco_stop(struct net_device *dev)
 {
-       del_timer_sync(&dev_to_hdlc(dev)->state.cisco.timer);
+       hdlc_device *hdlc = dev_to_hdlc(dev);
+       del_timer_sync(&hdlc->state.cisco.timer);
+#if 0
        if (netif_carrier_ok(dev))
                netif_carrier_off(dev);
+#endif
+       hdlc->state.cisco.up = 0;
+       hdlc->state.cisco.request_sent = 0;
 }
 
 
 
 int hdlc_cisco_ioctl(struct net_device *dev, struct ifreq *ifr)
 {
-       cisco_proto *cisco_s = ifr->ifr_settings.ifs_ifsu.cisco;
+       cisco_proto __user *cisco_s = ifr->ifr_settings.ifs_ifsu.cisco;
        const size_t size = sizeof(cisco_proto);
        cisco_proto new_settings;
        hdlc_device *hdlc = dev_to_hdlc(dev);