summaryrefslogtreecommitdiffstats
path: root/net/802
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1999-10-09 00:00:47 +0000
committerRalf Baechle <ralf@linux-mips.org>1999-10-09 00:00:47 +0000
commitd6434e1042f3b0a6dfe1b1f615af369486f9b1fa (patch)
treee2be02f33984c48ec019c654051d27964e42c441 /net/802
parent609d1e803baf519487233b765eb487f9ec227a18 (diff)
Merge with 2.3.19.
Diffstat (limited to 'net/802')
-rw-r--r--net/802/.cvsignore2
-rw-r--r--net/802/Makefile4
-rw-r--r--net/802/fc.c94
-rw-r--r--net/802/fddi.c4
-rw-r--r--net/802/hippi.c4
-rw-r--r--net/802/llc_macinit.c4
-rw-r--r--net/802/p8022.c8
-rw-r--r--net/802/p8023.c2
-rw-r--r--net/802/psnap.c6
-rw-r--r--net/802/tr.c50
10 files changed, 138 insertions, 40 deletions
diff --git a/net/802/.cvsignore b/net/802/.cvsignore
deleted file mode 100644
index 857dd22e9..000000000
--- a/net/802/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-.depend
-.*.flags
diff --git a/net/802/Makefile b/net/802/Makefile
index cdfafc343..66f8af658 100644
--- a/net/802/Makefile
+++ b/net/802/Makefile
@@ -26,6 +26,10 @@ O_OBJS += tr.o
SNAP=y
endif
+ifdef CONFIG_NET_FC
+O_OBJS += fc.o
+endif
+
ifdef CONFIG_FDDI
O_OBJS += fddi.o
endif
diff --git a/net/802/fc.c b/net/802/fc.c
new file mode 100644
index 000000000..723e7dae5
--- /dev/null
+++ b/net/802/fc.c
@@ -0,0 +1,94 @@
+/*
+ * NET3: Fibre Channel device handling subroutines
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Vineet Abraham <vma@iol.unh.edu>
+ * v 1.0 03/22/99
+ */
+
+#include <asm/uaccess.h>
+#include <asm/system.h>
+#include <linux/types.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/string.h>
+#include <linux/mm.h>
+#include <linux/socket.h>
+#include <linux/in.h>
+#include <linux/inet.h>
+#include <linux/netdevice.h>
+#include <linux/fcdevice.h>
+#include <linux/skbuff.h>
+#include <linux/errno.h>
+#include <linux/timer.h>
+#include <linux/net.h>
+#include <linux/proc_fs.h>
+#include <linux/init.h>
+#include <net/arp.h>
+
+/*
+ * Put the headers on a Fibre Channel packet.
+ */
+
+int fc_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
+ void *daddr, void *saddr, unsigned len)
+{
+ struct fch_hdr *fch;
+ int hdr_len;
+
+ /*
+ * Add the 802.2 SNAP header if IP as the IPv4 code calls
+ * dev->hard_header directly.
+ */
+ if (type == ETH_P_IP || type == ETH_P_ARP)
+ {
+ struct fcllc *fcllc=(struct fcllc *)(fch+1);
+
+ hdr_len = sizeof(struct fch_hdr) + sizeof(struct fcllc);
+ fch = (struct fch_hdr *)skb_push(skb, hdr_len);
+ fcllc = (struct fcllc *)(fch+1);
+ fcllc->dsap = fcllc->ssap = EXTENDED_SAP;
+ fcllc->llc = UI_CMD;
+ fcllc->protid[0] = fcllc->protid[1] = fcllc->protid[2] = 0x00;
+ fcllc->ethertype = htons(type);
+ }
+ else
+ {
+ hdr_len = sizeof(struct fch_hdr);
+ fch = (struct fch_hdr *)skb_push(skb, hdr_len);
+ }
+
+ if(saddr)
+ memcpy(fch->saddr,saddr,dev->addr_len);
+ else
+ memcpy(fch->saddr,dev->dev_addr,dev->addr_len);
+
+ if(daddr)
+ {
+ memcpy(fch->daddr,daddr,dev->addr_len);
+ return(hdr_len);
+ }
+ return -hdr_len;
+}
+
+/*
+ * A neighbour discovery of some species (eg arp) has completed. We
+ * can now send the packet.
+ */
+
+int fc_rebuild_header(struct sk_buff *skb)
+{
+ struct fch_hdr *fch=(struct fch_hdr *)skb->data;
+ struct fcllc *fcllc=(struct fcllc *)(skb->data+sizeof(struct fch_hdr));
+ if(fcllc->ethertype != htons(ETH_P_IP)) {
+ printk("fc_rebuild_header: Don't know how to resolve type %04X addresses ?\n",(unsigned int)htons(fcllc->ethertype));
+ return 0;
+ }
+
+ return arp_find(fch->daddr, skb);
+}
+
diff --git a/net/802/fddi.c b/net/802/fddi.c
index afe14c384..4dccc3a9e 100644
--- a/net/802/fddi.c
+++ b/net/802/fddi.c
@@ -51,7 +51,7 @@
* daddr=NULL means leave destination address (eg unresolved arp)
*/
-int fddi_header(struct sk_buff *skb, struct device *dev, unsigned short type,
+int fddi_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
void *daddr, void *saddr, unsigned len)
{
int hl = FDDI_K_SNAP_HLEN;
@@ -120,7 +120,7 @@ int fddi_rebuild_header(struct sk_buff *skb)
* the proper pointer to the start of packet data (skb->data).
*/
-unsigned short fddi_type_trans(struct sk_buff *skb, struct device *dev)
+unsigned short fddi_type_trans(struct sk_buff *skb, struct net_device *dev)
{
struct fddihdr *fddi = (struct fddihdr *)skb->data;
unsigned short type;
diff --git a/net/802/hippi.c b/net/802/hippi.c
index f1dd1dd17..daaea997c 100644
--- a/net/802/hippi.c
+++ b/net/802/hippi.c
@@ -57,7 +57,7 @@ void hippi_net_init(void)
* daddr=NULL means leave destination address (eg unresolved arp)
*/
-int hippi_header(struct sk_buff *skb, struct device *dev,
+int hippi_header(struct sk_buff *skb, struct net_device *dev,
unsigned short type, void *daddr, void *saddr,
unsigned len)
{
@@ -133,7 +133,7 @@ int hippi_rebuild_header(struct sk_buff *skb)
* Determine the packet's protocol ID.
*/
-unsigned short hippi_type_trans(struct sk_buff *skb, struct device *dev)
+unsigned short hippi_type_trans(struct sk_buff *skb, struct net_device *dev)
{
struct hippi_hdr *hip;
diff --git a/net/802/llc_macinit.c b/net/802/llc_macinit.c
index da47f4883..792bfd5e8 100644
--- a/net/802/llc_macinit.c
+++ b/net/802/llc_macinit.c
@@ -160,7 +160,7 @@ int register_cl2llc_client(llcptr lp, const char *device, void (*event)(llcptr),
char eye_init[] = "LLC\0";
memset(lp, 0, sizeof(*lp));
- lp->dev = dev_get(device);
+ lp->dev = __dev_get_by_name(device);
if(lp->dev == NULL)
return -ENODEV;
memcpy(lp->eye, eye_init, sizeof(lp->eye));
@@ -204,7 +204,7 @@ EXPORT_SYMBOL(llc_cancel_timers);
#define ALL_TYPES_8022 0
-__initfunc(void llc_init(struct net_proto *proto))
+void __init llc_init(struct net_proto *proto)
{
printk(KERN_NOTICE "IEEE 802.2 LLC for Linux 2.1 (c) 1996 Tim Alpaerts\n");
return;
diff --git a/net/802/p8022.c b/net/802/p8022.c
index 70bc2162c..7d03668d2 100644
--- a/net/802/p8022.c
+++ b/net/802/p8022.c
@@ -47,7 +47,7 @@ static struct datalink_proto *find_8022_client(unsigned char type)
return proto;
}
-int p8022_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt)
+int p8022_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt)
{
struct datalink_proto *proto;
@@ -68,7 +68,7 @@ int p8022_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt)
static void p8022_datalink_header(struct datalink_proto *dl,
struct sk_buff *skb, unsigned char *dest_node)
{
- struct device *dev = skb->dev;
+ struct net_device *dev = skb->dev;
unsigned char *rawp;
rawp = skb_push(skb,3);
@@ -90,13 +90,13 @@ static struct packet_type p8022_packet_type =
EXPORT_SYMBOL(register_8022_client);
EXPORT_SYMBOL(unregister_8022_client);
-__initfunc(void p8022_proto_init(struct net_proto *pro))
+void __init p8022_proto_init(struct net_proto *pro)
{
p8022_packet_type.type=htons(ETH_P_802_2);
dev_add_pack(&p8022_packet_type);
}
-struct datalink_proto *register_8022_client(unsigned char type, int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *))
+struct datalink_proto *register_8022_client(unsigned char type, int (*rcvfunc)(struct sk_buff *, struct net_device *, struct packet_type *))
{
struct datalink_proto *proto;
diff --git a/net/802/p8023.c b/net/802/p8023.c
index 82a80c3c2..90ac32365 100644
--- a/net/802/p8023.c
+++ b/net/802/p8023.c
@@ -27,7 +27,7 @@
static void p8023_datalink_header(struct datalink_proto *dl,
struct sk_buff *skb, unsigned char *dest_node)
{
- struct device *dev = skb->dev;
+ struct net_device *dev = skb->dev;
dev->hard_header(skb, dev, ETH_P_802_3, dest_node, NULL, skb->len);
}
diff --git a/net/802/psnap.c b/net/802/psnap.c
index 8c077d46f..7d8b12047 100644
--- a/net/802/psnap.c
+++ b/net/802/psnap.c
@@ -39,7 +39,7 @@ static struct datalink_proto *find_snap_client(unsigned char *desc)
* A SNAP packet has arrived
*/
-int snap_rcv(struct sk_buff *skb, struct device *dev, struct packet_type *pt)
+int snap_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt)
{
static struct packet_type psnap_packet_type =
{
@@ -89,7 +89,7 @@ static void snap_datalink_header(struct datalink_proto *dl, struct sk_buff *skb,
EXPORT_SYMBOL(register_snap_client);
EXPORT_SYMBOL(unregister_snap_client);
-__initfunc(void snap_proto_init(struct net_proto *pro))
+void __init snap_proto_init(struct net_proto *pro)
{
snap_dl=register_8022_client(0xAA, snap_rcv);
if(snap_dl==NULL)
@@ -100,7 +100,7 @@ __initfunc(void snap_proto_init(struct net_proto *pro))
* Register SNAP clients. We don't yet use this for IP.
*/
-struct datalink_proto *register_snap_client(unsigned char *desc, int (*rcvfunc)(struct sk_buff *, struct device *, struct packet_type *))
+struct datalink_proto *register_snap_client(unsigned char *desc, int (*rcvfunc)(struct sk_buff *, struct net_device *, struct packet_type *))
{
struct datalink_proto *proto;
diff --git a/net/802/tr.c b/net/802/tr.c
index 9047eaa49..f3fa70ac1 100644
--- a/net/802/tr.c
+++ b/net/802/tr.c
@@ -36,8 +36,8 @@
#include <linux/init.h>
#include <net/arp.h>
-static void tr_source_route(struct sk_buff *skb, struct trh_hdr *trh, struct device *dev);
-static void tr_add_rif_info(struct trh_hdr *trh, struct device *dev);
+static void tr_source_route(struct sk_buff *skb, struct trh_hdr *trh, struct net_device *dev);
+static void tr_add_rif_info(struct trh_hdr *trh, struct net_device *dev);
static void rif_check_expire(unsigned long dummy);
#define TR_SR_DEBUG 0
@@ -50,7 +50,7 @@ typedef struct rif_cache_s *rif_cache;
struct rif_cache_s {
unsigned char addr[TR_ALEN];
- unsigned char iface[5];
+ int iface;
__u16 rcf;
__u16 rseg[8];
rif_cache next;
@@ -85,7 +85,7 @@ int sysctl_tr_rif_timeout = RIF_TIMEOUT;
* makes this a little more exciting than on ethernet.
*/
-int tr_header(struct sk_buff *skb, struct device *dev, unsigned short type,
+int tr_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
void *daddr, void *saddr, unsigned len)
{
struct trh_hdr *trh;
@@ -144,7 +144,7 @@ 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));
- struct device *dev = skb->dev;
+ struct net_device *dev = skb->dev;
/*
* FIXME: We don't yet support IPv6 over token rings
@@ -173,7 +173,7 @@ int tr_rebuild_header(struct sk_buff *skb)
* it via SNAP.
*/
-unsigned short tr_type_trans(struct sk_buff *skb, struct device *dev)
+unsigned short tr_type_trans(struct sk_buff *skb, struct net_device *dev)
{
struct trh_hdr *trh=(struct trh_hdr *)skb->data;
@@ -225,15 +225,14 @@ unsigned short tr_type_trans(struct sk_buff *skb, struct device *dev)
* We try to do source routing...
*/
-static void tr_source_route(struct sk_buff *skb,struct trh_hdr *trh,struct device *dev)
+static void tr_source_route(struct sk_buff *skb,struct trh_hdr *trh,struct net_device *dev)
{
int i, slack;
unsigned int hash;
rif_cache entry;
unsigned char *olddata;
- unsigned long flags;
- spin_lock_irqsave(&rif_lock, flags);
+ spin_lock_bh(&rif_lock);
/*
* Broadcasts are single route as stated in RFC 1042
@@ -302,7 +301,7 @@ printk("source routing for %02X %02X %02X %02X %02X %02X\n",trh->daddr[0],
else
slack = 18 - ((ntohs(trh->rcf) & TR_RCF_LEN_MASK)>>8);
olddata = skb->data;
- spin_unlock_irqrestore(&rif_lock, flags);
+ spin_unlock_bh(&rif_lock);
skb_pull(skb, slack);
memmove(skb->data, olddata, sizeof(struct trh_hdr) - slack);
@@ -313,15 +312,14 @@ printk("source routing for %02X %02X %02X %02X %02X %02X\n",trh->daddr[0],
* routing.
*/
-static void tr_add_rif_info(struct trh_hdr *trh, struct device *dev)
+static void tr_add_rif_info(struct trh_hdr *trh, struct net_device *dev)
{
int i;
unsigned int hash, rii_p = 0;
rif_cache entry;
- unsigned long flags;
- spin_lock_irqsave(&rif_lock, flags);
+ spin_lock_bh(&rif_lock);
/*
* Firstly see if the entry exists
@@ -360,12 +358,12 @@ printk("adding rif_entry: addr:%02X:%02X:%02X:%02X:%02X:%02X rcf:%04X\n",
if(!entry)
{
printk(KERN_DEBUG "tr.c: Couldn't malloc rif cache entry !\n");
- spin_unlock_irqrestore(&rif_lock, flags);
+ spin_unlock_bh(&rif_lock);
return;
}
memcpy(&(entry->addr[0]),&(trh->saddr[0]),TR_ALEN);
- memcpy(&(entry->iface[0]),dev->name,5);
+ entry->iface = dev->ifindex;
entry->next=rif_table[hash];
entry->last_used=jiffies;
rif_table[hash]=entry;
@@ -402,7 +400,7 @@ printk("updating rif_entry: addr:%02X:%02X:%02X:%02X:%02X:%02X rcf:%04X\n",
}
entry->last_used=jiffies;
}
- spin_unlock_irqrestore(&rif_lock, flags);
+ spin_unlock_bh(&rif_lock);
}
/*
@@ -412,9 +410,9 @@ printk("updating rif_entry: addr:%02X:%02X:%02X:%02X:%02X:%02X rcf:%04X\n",
static void rif_check_expire(unsigned long dummy)
{
int i;
- unsigned long now=jiffies,flags;
+ unsigned long now=jiffies;
- spin_lock_irqsave(&rif_lock, flags);
+ spin_lock(&rif_lock);
for(i=0; i < RIF_TABLE_SIZE;i++)
{
@@ -434,15 +432,13 @@ static void rif_check_expire(unsigned long dummy)
}
}
- spin_unlock_irqrestore(&rif_lock, flags);
+ spin_unlock(&rif_lock);
/*
* Reset the timer
*/
- del_timer(&rif_timer);
- rif_timer.expires = jiffies + sysctl_tr_rif_timeout;
- add_timer(&rif_timer);
+ mod_timer(&rif_timer, jiffies+sysctl_tr_rif_timeout);
}
@@ -467,11 +463,14 @@ int rif_get_info(char *buffer,char **start, off_t offset, int length, int dummy)
pos+=size;
len+=size;
+ spin_lock_bh(&rif_lock);
for(i=0;i < RIF_TABLE_SIZE;i++)
{
for(entry=rif_table[i];entry;entry=entry->next) {
+ struct net_device *dev = __dev_get_by_index(entry->iface);
+
size=sprintf(buffer+len,"%s %02X:%02X:%02X:%02X:%02X:%02X %7li ",
- entry->iface,entry->addr[0],entry->addr[1],entry->addr[2],entry->addr[3],entry->addr[4],entry->addr[5],
+ dev?dev->name:"?",entry->addr[0],entry->addr[1],entry->addr[2],entry->addr[3],entry->addr[4],entry->addr[5],
sysctl_tr_rif_timeout-(now-entry->last_used));
len+=size;
pos=begin+len;
@@ -513,11 +512,14 @@ int rif_get_info(char *buffer,char **start, off_t offset, int length, int dummy)
if(pos>offset+length)
break;
}
+ spin_unlock_bh(&rif_lock);
*start=buffer+(offset-begin); /* Start of wanted data */
len-=(offset-begin); /* Start slop */
if(len>length)
len=length; /* Ending slop */
+ if (len<0)
+ len=0;
return len;
}
#endif
@@ -536,7 +538,7 @@ static struct proc_dir_entry tr_rif_proc = {
};
#endif
-__initfunc(void rif_init(struct net_proto *unused))
+void __init rif_init(struct net_proto *unused)
{
rif_timer.expires = RIF_TIMEOUT;
rif_timer.data = 0L;