Merge to kernel-2.6.20-1.2949.fc6.vs2.2.0.1
[linux-2.6.git] / net / 802 / tr.c
index f297f86..829deb4 100644 (file)
@@ -17,7 +17,6 @@
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
@@ -47,12 +46,12 @@ static void rif_check_expire(unsigned long dummy);
  *     Each RIF entry we learn is kept this way
  */
  
-struct rif_cache_s {   
+struct rif_cache {
        unsigned char addr[TR_ALEN];
        int iface;
-       __u16 rcf;
-       __u16 rseg[8];
-       struct rif_cache_s *next;
+       __be16 rcf;
+       __be16 rseg[8];
+       struct rif_cache *next;
        unsigned long last_used;
        unsigned char local_ring;
 };
@@ -64,9 +63,9 @@ struct rif_cache_s {
  *     up a lot.
  */
  
-static struct rif_cache_s *rif_table[RIF_TABLE_SIZE];
+static struct rif_cache *rif_table[RIF_TABLE_SIZE];
 
-static spinlock_t rif_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(rif_lock);
 
 
 /*
@@ -98,8 +97,9 @@ static inline unsigned long rif_hash(const unsigned char *addr)
  *     makes this a little more exciting than on ethernet.
  */
  
-int tr_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
-              void *daddr, void *saddr, unsigned len) 
+static int tr_header(struct sk_buff *skb, struct net_device *dev,
+                    unsigned short type,
+                    void *daddr, void *saddr, unsigned len) 
 {
        struct trh_hdr *trh;
        int hdr_len;
@@ -153,7 +153,7 @@ int tr_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
  *     can now send the packet.
  */
  
-int tr_rebuild_header(struct sk_buff *skb) 
+static int tr_rebuild_header(struct sk_buff *skb) 
 {
        struct trh_hdr *trh=(struct trh_hdr *)skb->data;
        struct trllc *trllc=(struct trllc *)(skb->data+sizeof(struct trh_hdr));
@@ -164,7 +164,7 @@ int tr_rebuild_header(struct sk_buff *skb)
         */
         
        if(trllc->ethertype != htons(ETH_P_IP)) {
-               printk("tr_rebuild_header: Don't know how to resolve type %04X addresses ?\n",(unsigned int)htons(trllc->ethertype));
+               printk("tr_rebuild_header: Don't know how to resolve type %04X addresses ?\n", ntohs(trllc->ethertype));
                return 0;
        }
 
@@ -186,7 +186,7 @@ int tr_rebuild_header(struct sk_buff *skb)
  *     it via SNAP.
  */
  
-unsigned short tr_type_trans(struct sk_buff *skb, struct net_device *dev) 
+__be16 tr_type_trans(struct sk_buff *skb, struct net_device *dev)
 {
 
        struct trh_hdr *trh=(struct trh_hdr *)skb->data;
@@ -229,15 +229,15 @@ unsigned short tr_type_trans(struct sk_buff *skb, struct net_device *dev)
         */
 
        if (trllc->dsap == EXTENDED_SAP &&
-           (trllc->ethertype == ntohs(ETH_P_IP) ||
-            trllc->ethertype == ntohs(ETH_P_IPV6) ||
-            trllc->ethertype == ntohs(ETH_P_ARP)))
+           (trllc->ethertype == htons(ETH_P_IP) ||
+            trllc->ethertype == htons(ETH_P_IPV6) ||
+            trllc->ethertype == htons(ETH_P_ARP)))
        {
                skb_pull(skb, sizeof(struct trllc));
                return trllc->ethertype;
        }
 
-       return ntohs(ETH_P_802_2);
+       return htons(ETH_P_TR_802_2);
 }
 
 /*
@@ -248,7 +248,7 @@ void tr_source_route(struct sk_buff *skb,struct trh_hdr *trh,struct net_device *
 {
        int slack;
        unsigned int hash;
-       struct rif_cache_s *entry;
+       struct rif_cache *entry;
        unsigned char *olddata;
        unsigned long flags;
        static const unsigned char mcast_func_addr[] 
@@ -338,10 +338,11 @@ static void tr_add_rif_info(struct trh_hdr *trh, struct net_device *dev)
 {
        unsigned int hash, rii_p = 0;
        unsigned long flags;
-       struct rif_cache_s *entry;
-
+       struct rif_cache *entry;
+       unsigned char saddr0;
 
        spin_lock_irqsave(&rif_lock, flags);
+       saddr0 = trh->saddr[0];
        
        /*
         *      Firstly see if the entry exists
@@ -374,7 +375,7 @@ printk("adding rif_entry: addr:%02X:%02X:%02X:%02X:%02X:%02X rcf:%04X\n",
                 *      FIXME: We ought to keep some kind of cache size
                 *      limiting and adjust the timers to suit.
                 */
-               entry=kmalloc(sizeof(struct rif_cache_s),GFP_ATOMIC);
+               entry=kmalloc(sizeof(struct rif_cache),GFP_ATOMIC);
 
                if(!entry) 
                {
@@ -394,7 +395,6 @@ printk("adding rif_entry: addr:%02X:%02X:%02X:%02X:%02X:%02X rcf:%04X\n",
                        entry->rcf = trh->rcf & htons((unsigned short)~TR_RCF_BROADCAST_MASK);
                        memcpy(&(entry->rseg[0]),&(trh->rseg[0]),8*sizeof(unsigned short));
                        entry->local_ring = 0;
-                       trh->saddr[0]|=TR_RII; /* put the routing indicator back for tcpdump */
                }
                else
                {
@@ -421,6 +421,7 @@ printk("updating rif_entry: addr:%02X:%02X:%02X:%02X:%02X:%02X rcf:%04X\n",
                    }                                         
                entry->last_used=jiffies;               
        }
+       trh->saddr[0]=saddr0; /* put the routing indicator back for tcpdump */
        spin_unlock_irqrestore(&rif_lock, flags);
 }
 
@@ -436,7 +437,7 @@ static void rif_check_expire(unsigned long dummy)
        spin_lock_irqsave(&rif_lock, flags);
        
        for(i =0; i < RIF_TABLE_SIZE; i++) {
-               struct rif_cache_s *entry, **pentry;
+               struct rif_cache *entry, **pentry;
                
                pentry = rif_table+i;
                while((entry=*pentry) != NULL) {
@@ -468,10 +469,10 @@ static void rif_check_expire(unsigned long dummy)
  
 #ifdef CONFIG_PROC_FS
 
-static struct rif_cache_s *rif_get_idx(loff_t pos)
+static struct rif_cache *rif_get_idx(loff_t pos)
 {
        int i;
-       struct rif_cache_s *entry;
+       struct rif_cache *entry;
        loff_t off = 0;
 
        for(i = 0; i < RIF_TABLE_SIZE; i++) 
@@ -494,7 +495,7 @@ static void *rif_seq_start(struct seq_file *seq, loff_t *pos)
 static void *rif_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
        int i;
-       struct rif_cache_s *ent = v;
+       struct rif_cache *ent = v;
 
        ++*pos;
 
@@ -523,7 +524,7 @@ static void rif_seq_stop(struct seq_file *seq, void *v)
 static int rif_seq_show(struct seq_file *seq, void *v)
 {
        int j, rcf_len, segment, brdgnmb;
-       struct rif_cache_s *entry = v;
+       struct rif_cache *entry = v;
 
        if (v == SEQ_START_TOKEN)
                seq_puts(seq,
@@ -641,6 +642,5 @@ static int __init rif_init(void)
 
 module_init(rif_init);
 
-EXPORT_SYMBOL(tr_source_route);
 EXPORT_SYMBOL(tr_type_trans);
 EXPORT_SYMBOL(alloc_trdev);