Commit 54c8c5d8 authored by Linus Torvalds's avatar Linus Torvalds

Merge master.kernel.org:/home/davem/BK/net-2.5

into penguin.transmeta.com:/home/penguin/torvalds/repositories/kernel/linux
parents b85e4ca0 a5ea51da
......@@ -3,7 +3,6 @@
#
mainmenu_option next_comment
comment 'Appletalk devices'
dep_mbool 'Appletalk interfaces support' CONFIG_DEV_APPLETALK $CONFIG_ATALK
if [ "$CONFIG_DEV_APPLETALK" = "y" ]; then
tristate ' Apple/Farallon LocalTalk PC support' CONFIG_LTPC
......@@ -18,4 +17,3 @@ if [ "$CONFIG_DEV_APPLETALK" = "y" ]; then
bool ' Appletalk-IP to IP Decapsulation support' CONFIG_IPDDP_DECAP
fi
fi
endmenu
......@@ -181,7 +181,7 @@ struct cops_local
int board; /* Holds what board type is. */
int nodeid; /* Set to 1 once have nodeid. */
unsigned char node_acquire; /* Node ID when acquired. */
struct at_addr node_addr; /* Full node address */
struct atalk_addr node_addr; /* Full node address */
};
/* Index to functions, as function prototypes. */
......@@ -955,8 +955,8 @@ static int cops_hard_header(struct sk_buff *skb, struct net_device *dev,
static int cops_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
struct cops_local *lp = (struct cops_local *)dev->priv;
struct sockaddr_at *sa=(struct sockaddr_at *)&ifr->ifr_addr;
struct at_addr *aa=(struct at_addr *)&lp->node_addr;
struct sockaddr_at *sa = (struct sockaddr_at *)&ifr->ifr_addr;
struct atalk_addr *aa = (struct atalk_addr *)&lp->node_addr;
switch(cmd)
{
......
......@@ -116,7 +116,7 @@ static int ipddp_xmit(struct sk_buff *skb, struct net_device *dev)
u32 paddr = ((struct rtable*)skb->dst)->rt_gateway;
struct ddpehdr *ddp;
struct ipddp_route *rt;
struct at_addr *our_addr;
struct atalk_addr *our_addr;
/*
* Find appropriate route to use, based only on IP number.
......
......@@ -15,7 +15,7 @@ struct ipddp_route
{
struct net_device *dev; /* Carrier device */
__u32 ip; /* IP address */
struct at_addr at; /* Gateway appletalk address */
struct atalk_addr at; /* Gateway appletalk address */
int flags;
struct ipddp_route *next;
};
......
......@@ -262,7 +262,7 @@ static unsigned char *ltdmacbuf;
struct ltpc_private
{
struct net_device_stats stats;
struct at_addr my_addr;
struct atalk_addr my_addr;
};
/* transmit queue element struct */
......@@ -826,7 +826,7 @@ static int ltpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
struct sockaddr_at *sa = (struct sockaddr_at *) &ifr->ifr_addr;
/* we'll keep the localtalk node address in dev->pa_addr */
struct at_addr *aa = &((struct ltpc_private *)dev->priv)->my_addr;
struct atalk_addr *aa = &((struct ltpc_private *)dev->priv)->my_addr;
struct lt_init c;
int ltflags;
......
......@@ -399,7 +399,7 @@ static u16 bond_check_dev_link(struct net_device *dev)
{
static int (* ioctl)(struct net_device *, struct ifreq *, int);
struct ifreq ifr;
struct mii_ioctl_data mii;
struct mii_ioctl_data *mii;
struct ethtool_value etool;
if ((ioctl = dev->do_ioctl) != NULL) { /* ioctl to access MII */
......@@ -425,21 +425,24 @@ static u16 bond_check_dev_link(struct net_device *dev)
}
}
ifr.ifr_data = (char*)&mii;
/* try MIIPHY first then, if that doesn't work, try MIIREG */
if (ioctl(dev, &ifr, SIOCGMIIPHY) == 0) {
/* now, mii.phy_id contains info about link status :
- mii.phy_id & 0x04 means link up
- mii.phy_id & 0x20 means end of auto-negociation
*/
return mii.phy_id;
/*
* We cannot assume that SIOCGMIIPHY will also read a
* register; not all network drivers support that.
*/
/* Yes, the mii is overlaid on the ifreq.ifr_ifru */
mii = (struct mii_ioctl_data *)&ifr.ifr_data;
if (ioctl(dev, &ifr, SIOCGMIIPHY) != 0) {
return MII_LINK_READY; /* can't tell */
}
mii.reg_num = 1; /* the MII register we want to read */
mii->reg_num = 1;
if (ioctl(dev, &ifr, SIOCGMIIREG) == 0) {
/* mii.val_out contians the same link info as phy_id */
/* above */
return mii.val_out;
/*
* mii->val_out contains MII reg 1, BMSR
* 0x0004 means link established
*/
return mii->val_out;
}
}
......@@ -641,12 +644,6 @@ static void set_multicast_list(struct net_device *master)
*/
write_lock_irqsave(&bond->lock, flags);
/*
* Lock the master device so that noone trys to transmit
* while we're changing things
*/
spin_lock_bh(&master->xmit_lock);
/* set promiscuity flag to slaves */
if ( (master->flags & IFF_PROMISC) && !(bond->flags & IFF_PROMISC) )
bond_set_promiscuity(bond, 1);
......@@ -680,7 +677,6 @@ static void set_multicast_list(struct net_device *master)
bond_mc_list_destroy (bond);
bond_mc_list_copy (master->mc_list, bond, GFP_KERNEL);
spin_unlock_bh(&master->xmit_lock);
write_unlock_irqrestore(&bond->lock, flags);
}
......
......@@ -29,13 +29,11 @@
* compare-and-swap cpus (Sparc64). So we control which
* implementation to use with a __BRLOCK_USE_ATOMICS define. -DaveM
*
* Added BR_LLC_LOCK for use in net/core/ext8022.c -acme
*/
/* Register bigreader lock indices here. */
enum brlock_indices {
BR_NETPROTO_LOCK,
BR_LLC_LOCK,
__BR_END
};
......
......@@ -12,6 +12,7 @@
#include <linux/stddef.h>
#include <linux/types.h>
#include <linux/compiler.h>
#include <asm/byteorder.h>
/* Optimization barrier */
/* The "volatile" is due to gcc bugs */
......@@ -116,11 +117,17 @@ extern const char *print_tainted(void);
((unsigned char *)&addr)[2], \
((unsigned char *)&addr)[3]
#if defined(__LITTLE_ENDIAN)
#define HIPQUAD(addr) \
((unsigned char *)&addr)[3], \
((unsigned char *)&addr)[2], \
((unsigned char *)&addr)[1], \
((unsigned char *)&addr)[0]
#elif defined(__BIG_ENDIAN)
#define HIPQUAD NIPQUAD
#else
#error "Please fix asm/byteorder.h"
#endif /* __LITTLE_ENDIAN */
/*
* min()/max() macros that also do
......
......@@ -162,7 +162,7 @@ struct netif_rx_stats
unsigned fastroute_deferred_out;
unsigned fastroute_latency_reduction;
unsigned cpu_collision;
} __attribute__ ((__aligned__(SMP_CACHE_BYTES)));
} ____cacheline_aligned;
extern struct netif_rx_stats netdev_rx_stat[];
......@@ -376,6 +376,7 @@ struct net_device
int (*stop)(struct net_device *dev);
int (*hard_start_xmit) (struct sk_buff *skb,
struct net_device *dev);
#define HAVE_NETDEV_POLL
int (*poll) (struct net_device *dev, int *quota);
int (*hard_header) (struct sk_buff *skb,
struct net_device *dev,
......@@ -501,7 +502,7 @@ struct softnet_data
struct sk_buff *completion_queue;
struct net_device backlog_dev; /* Sorry. 8) */
} __attribute__((__aligned__(SMP_CACHE_BYTES)));
} ____cacheline_aligned;
extern struct softnet_data softnet_data[NR_CPUS];
......
......@@ -2,24 +2,17 @@
#define _NET_INET_DATALINK_H_
struct datalink_proto {
unsigned short type_len;
unsigned char type[8];
const char *string_name;
union {
struct llc_pinfo *llc;
} ll_pinfo;
struct llc_sc_info *llc_sc;
struct sock *sock;
struct llc_sap *sap;
unsigned short header_length;
int (*rcvfunc)(struct sk_buff *, struct net_device *,
struct packet_type *);
void (*datalink_header)(struct datalink_proto *, struct sk_buff *,
int (*request)(struct datalink_proto *, struct sk_buff *,
unsigned char *);
struct datalink_proto *next;
struct list_head node;
};
#endif
......@@ -29,8 +29,6 @@
#define LLC_GLOBAL_DEFAULT_MAX_NBR_SAPS 4
#define LLC_GLOBAL_DEFAULT_MAX_NBR_CONNS 64
extern struct llc_prim_if_block llc_ind_prim, llc_cfm_prim;
/* LLC station component (SAP and connection resource manager) */
/* Station component; one per adapter */
struct llc_station {
......
......@@ -198,6 +198,11 @@ struct llc_pdu_sn {
u8 ctrl_2;
};
static __inline__ struct llc_pdu_sn *llc_pdu_sn_hdr(struct sk_buff *skb)
{
return (struct llc_pdu_sn *)skb->nh.raw;
}
/* Un-numbered PDU format (3 bytes in length) */
struct llc_pdu_un {
u8 dsap;
......@@ -205,6 +210,16 @@ struct llc_pdu_un {
u8 ctrl_1;
};
static __inline__ struct llc_pdu_un *llc_pdu_un_hdr(struct sk_buff *skb)
{
return (struct llc_pdu_un *)skb->nh.raw;
}
static __inline__ void *llc_set_pdu_hdr(struct sk_buff *skb, void *ptr)
{
return skb->nh.raw = ptr;
}
/* LLC Type 1 XID command/response information fields format */
struct llc_xid_info {
u8 fmt_id; /* always 0x18 for LLC */
......
......@@ -12,23 +12,38 @@
* See the GNU General Public License for more details.
*/
#include <linux/skbuff.h>
/* Defines the SAP component */
/**
* struct llc_sap - Defines the SAP component
*
* @p_bit - only lowest-order bit used
* @f_bit - only lowest-order bit used
* @req - provided by LLC layer
* @resp - provided by LLC layer
* @ind - provided by network layer
* @conf - provided by network layer
* @laddr - SAP value in this 'lsap'
* @node - entry in station sap_list
* @sk_list - LLC sockets this one manages
* @mac_pdu_q - PDUs ready to send to MAC
*/
struct llc_sap {
u8 state;
struct llc_station *parent_station;
u8 p_bit; /* only lowest-order bit used */
u8 f_bit; /* only lowest-order bit used */
llc_prim_call_t req; /* provided by LLC layer */
llc_prim_call_t resp; /* provided by LLC layer */
llc_prim_call_t ind; /* provided by network layer */
llc_prim_call_t conf; /* provided by network layer */
struct llc_addr laddr; /* SAP value in this 'lsap' */
struct list_head node; /* entry in station sap_list */
struct llc_station *parent_station;
u8 state;
u8 p_bit;
u8 f_bit;
llc_prim_call_t req;
llc_prim_call_t resp;
llc_prim_call_t ind;
llc_prim_call_t conf;
struct llc_prim_if_block llc_ind_prim, llc_cfm_prim;
union llc_u_prim_data llc_ind_data_prim, llc_cfm_data_prim;
struct llc_addr laddr;
struct list_head node;
struct {
spinlock_t lock;
struct list_head list;
} sk_list; /* LLC sockets this one manages */
struct sk_buff_head mac_pdu_q; /* PDUs ready to send to MAC */
} sk_list;
struct sk_buff_head mac_pdu_q;
};
struct llc_sap_state_ev;
......
#ifndef _NET_P8022_H
#define _NET_P8022_H
#include <net/llc_if.h>
extern struct datalink_proto *register_8022_client(unsigned char type,
int (*rcvfunc)
(struct sk_buff *,
struct net_device *,
struct packet_type *));
extern void unregister_8022_client(unsigned char type);
int (*indicate)(struct llc_prim_if_block *prim));
extern void unregister_8022_client(struct datalink_proto *proto);
#endif
......@@ -2,6 +2,6 @@
#define _NET_PSNAP_H
extern struct datalink_proto *register_snap_client(unsigned char *desc, int (*rcvfunc)(struct sk_buff *, struct net_device *, struct packet_type *));
extern void unregister_snap_client(unsigned char *desc);
extern void unregister_snap_client(struct datalink_proto *proto);
#endif
......@@ -23,103 +23,48 @@
#include <linux/in.h>
#include <linux/init.h>
#include <net/p8022.h>
#include <net/llc_sap.h>
extern void llc_register_sap(unsigned char sap,
int (*rcvfunc)(struct sk_buff *,
struct net_device *,
struct packet_type *));
extern void llc_unregister_sap(unsigned char sap);
static struct datalink_proto *p8022_list;
/*
* We don't handle the loopback SAP stuff, the extended
* 802.2 command set, multicast SAP identifiers and non UI
* frames. We have the absolute minimum needed for IPX,
* IP and Appletalk phase 2. See the llc_* routines for
* support libraries if your protocol needs these.
*/
static struct datalink_proto *find_8022_client(unsigned char type)
{
struct datalink_proto *proto = p8022_list;
while (proto && *(proto->type) != type)
proto = proto->next;
return proto;
}
int p8022_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt)
{
struct datalink_proto *proto;
int rc = 0;
proto = find_8022_client(*(skb->h.raw));
if (!proto) {
skb->sk = NULL;
kfree_skb(skb);
goto out;
}
skb->h.raw += 3;
skb->nh.raw += 3;
skb_pull(skb, 3);
rc = proto->rcvfunc(skb, dev, pt);
out: return rc;
}
static void p8022_datalink_header(struct datalink_proto *dl,
struct sk_buff *skb, unsigned char *dest_node)
static int p8022_request(struct datalink_proto *dl, struct sk_buff *skb,
unsigned char *dest)
{
struct net_device *dev = skb->dev;
unsigned char *rawp = skb_push(skb, 3);
union llc_u_prim_data prim_data;
struct llc_prim_if_block prim;
*rawp++ = dl->type[0];
*rawp++ = dl->type[0];
*rawp = 0x03; /* UI */
dev->hard_header(skb, dev, ETH_P_802_3, dest_node, NULL, skb->len);
prim.data = &prim_data;
prim.sap = dl->sap;
prim.prim = LLC_DATAUNIT_PRIM;
prim_data.test.skb = skb;
prim_data.test.saddr.lsap = dl->sap->laddr.lsap;
prim_data.test.daddr.lsap = dl->sap->laddr.lsap;
memcpy(prim_data.test.saddr.mac, skb->dev->dev_addr, IFHWADDRLEN);
memcpy(prim_data.test.daddr.mac, dest, IFHWADDRLEN);
return dl->sap->req(&prim);
}
struct datalink_proto *register_8022_client(unsigned char type,
int (*rcvfunc)(struct sk_buff *,
struct net_device *,
struct packet_type *))
int (*indicate)(struct llc_prim_if_block *prim))
{
struct datalink_proto *proto = NULL;
struct datalink_proto *proto;
if (find_8022_client(type))
goto out;
proto = kmalloc(sizeof(*proto), GFP_ATOMIC);
if (proto) {
proto->type[0] = type;
proto->type_len = 1;
proto->rcvfunc = rcvfunc;
proto->header_length = 3;
proto->datalink_header = p8022_datalink_header;
proto->string_name = "802.2";
proto->next = p8022_list;
p8022_list = proto;
llc_register_sap(type, p8022_rcv);
proto->request = p8022_request;
proto->sap = llc_sap_open(indicate, NULL, type);
if (!proto->sap) {
kfree(proto);
proto = NULL;
}
}
out: return proto;
return proto;
}
void unregister_8022_client(unsigned char type)
void unregister_8022_client(struct datalink_proto *proto)
{
struct datalink_proto *tmp, **clients = &p8022_list;
unsigned long flags;
save_flags(flags);
cli();
while (*clients) {
tmp = *clients;
if (tmp->type[0] == type) {
*clients = tmp->next;
kfree(tmp);
llc_unregister_sap(type);
break;
}
clients = &tmp->next;
}
restore_flags(flags);
llc_sap_close(proto->sap);
kfree(proto);
}
EXPORT_SYMBOL(register_8022_client);
......
......@@ -24,11 +24,12 @@
* addresses, we just need to give it the buffer length.
*/
static void p8023_datalink_header(struct datalink_proto *dl,
static int p8023_request(struct datalink_proto *dl,
struct sk_buff *skb, unsigned char *dest_node)
{
struct net_device *dev = skb->dev;
dev->hard_header(skb, dev, ETH_P_802_3, dest_node, NULL, skb->len);
return dev_queue_xmit(skb);
}
/*
......@@ -42,10 +43,8 @@ struct datalink_proto *make_8023_client(void)
proto = (struct datalink_proto *) kmalloc(sizeof(*proto), GFP_ATOMIC);
if (proto != NULL)
{
proto->type_len = 0;
proto->header_length = 0;
proto->datalink_header = p8023_datalink_header;
proto->string_name = "802.3";
proto->request = p8023_request;
}
return proto;
}
......
......@@ -15,61 +15,90 @@
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <net/datalink.h>
#include <net/p8022.h>
#include <net/psnap.h>
#include <net/llc_if.h>
#include <net/llc_sap.h>
#include <linux/mm.h>
#include <linux/in.h>
#include <linux/init.h>
#include <linux/brlock.h>
static struct datalink_proto *snap_list;
static struct datalink_proto *snap_dl; /* 802.2 DL for SNAP */
LIST_HEAD(snap_list);
static struct llc_sap *snap_sap;
/*
* Find a snap client by matching the 5 bytes.
*/
static struct datalink_proto *find_snap_client(unsigned char *desc)
{
struct datalink_proto *proto = snap_list;
struct list_head *entry;
struct datalink_proto *proto = NULL, *p;
for (; proto && memcmp(proto->type, desc, 5); proto = proto->next);
if (list_empty(&snap_list))
goto out;
list_for_each(entry, &snap_list) {
p = list_entry(entry, struct datalink_proto, node);
if (!memcmp(p->type, desc, 5)) {
proto = p;
break;
}
}
out:
return proto;
}
/*
* A SNAP packet has arrived
*/
int snap_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt)
static int snap_indicate(struct llc_prim_if_block *prim)
{
struct sk_buff *skb;
struct datalink_proto *proto;
int rc = 1;
static struct packet_type psnap_packet_type = {
.type = __constant_htons(ETH_P_SNAP),
.func = snap_rcv,
};
struct datalink_proto *proto = find_snap_client(skb->h.raw);
if (prim->prim != LLC_DATAUNIT_PRIM)
goto out;
skb = prim->data->udata.skb;
proto = find_snap_client(skb->h.raw);
if (proto) {
/* Pass the frame on. */
skb->h.raw += 5;
skb->nh.raw += 5;
skb_pull(skb, 5);
return proto->rcvfunc(skb, dev, &psnap_packet_type);
rc = proto->rcvfunc(skb, skb->dev, &psnap_packet_type);
} else {
skb->sk = NULL;
kfree_skb(skb);
rc = 1;
}
skb->sk = NULL;
kfree_skb(skb);
return 0;
out:
return rc;
}
/*
* Put a SNAP header on a frame and pass to 802.2
*/
static void snap_datalink_header(struct datalink_proto *dl,
struct sk_buff *skb, unsigned char *dest_node)
static int snap_request(struct datalink_proto *dl,
struct sk_buff *skb, u8 *dest)
{
union llc_u_prim_data prim_data;
struct llc_prim_if_block prim;
memcpy(skb_push(skb, 5), dl->type, 5);
snap_dl->datalink_header(snap_dl, skb, dest_node);
prim.data = &prim_data;
prim.sap = snap_sap;
prim.prim = LLC_DATAUNIT_PRIM;
prim_data.test.skb = skb;
prim_data.test.saddr.lsap = snap_sap->laddr.lsap;
prim_data.test.daddr.lsap = snap_sap->laddr.lsap;
memcpy(prim_data.test.saddr.mac, skb->dev->dev_addr, IFHWADDRLEN);
memcpy(prim_data.test.daddr.mac, dest, IFHWADDRLEN);
return snap_sap->req(&prim);
}
/*
......@@ -80,9 +109,9 @@ EXPORT_SYMBOL(unregister_snap_client);
static int __init snap_init(void)
{
snap_dl = register_8022_client(0xAA, snap_rcv);
snap_sap = llc_sap_open(snap_indicate, NULL, 0xAA);
if (!snap_dl)
if (!snap_sap)
printk(KERN_CRIT "SNAP - unable to register with 802.2\n");
return 0;
......@@ -90,6 +119,14 @@ static int __init snap_init(void)
module_init(snap_init);
static void __exit snap_exit(void)
{
llc_sap_close(snap_sap);
}
module_exit(snap_exit);
/*
* Register SNAP clients. We don't yet use this for IP.
*/
......@@ -100,46 +137,35 @@ struct datalink_proto *register_snap_client(unsigned char *desc,
{
struct datalink_proto *proto = NULL;
br_write_lock_bh(BR_NETPROTO_LOCK);
if (find_snap_client(desc))
goto out;
proto = kmalloc(sizeof(*proto), GFP_ATOMIC);
if (proto) {
memcpy(proto->type, desc,5);
proto->type_len = 5;
proto->rcvfunc = rcvfunc;
proto->header_length = 5 + snap_dl->header_length;
proto->datalink_header = snap_datalink_header;
proto->string_name = "SNAP";
proto->next = snap_list;
snap_list = proto;
proto->header_length = 5 + 3; /* snap + 802.2 */
proto->request = snap_request;
list_add(&proto->node, &snap_list);
}
out:
br_write_unlock_bh(BR_NETPROTO_LOCK);
return proto;
}
/*
* Unregister SNAP clients. Protocols no longer want to play with us ...
*/
void unregister_snap_client(unsigned char *desc)
void unregister_snap_client(struct datalink_proto *proto)
{
struct datalink_proto **clients = &snap_list;
struct datalink_proto *tmp;
unsigned long flags;
save_flags(flags);
cli();
br_write_lock_bh(BR_NETPROTO_LOCK);
while ((tmp = *clients) != NULL) {
if (!memcmp(tmp->type, desc, 5)) {
*clients = tmp->next;
kfree(tmp);
break;
} else
clients = &tmp->next;
}
list_del(&proto->node);
kfree(proto);
restore_flags(flags);
br_write_unlock_bh(BR_NETPROTO_LOCK);
}
MODULE_LICENSE("GPL");
......@@ -44,13 +44,17 @@ if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
fi
tristate '802.1Q VLAN Support' CONFIG_VLAN_8021Q
comment ' '
tristate 'The IPX protocol' CONFIG_IPX
tristate 'ANSI/IEEE 802.2 Data link layer protocol' CONFIG_LLC
if [ "$CONFIG_LLC" != "n" ]; then
tristate ' LLC sockets interface' CONFIG_LLC_UI
fi
dep_tristate 'The IPX protocol' CONFIG_IPX $CONFIG_LLC
if [ "$CONFIG_IPX" != "n" ]; then
source net/ipx/Config.in
fi
tristate 'Appletalk protocol support' CONFIG_ATALK
dep_tristate 'Appletalk protocol support' CONFIG_ATALK $CONFIG_LLC
source drivers/net/appletalk/Config.in
tristate 'DECnet Support' CONFIG_DECNET
......@@ -61,11 +65,6 @@ dep_tristate '802.1d Ethernet Bridging' CONFIG_BRIDGE $CONFIG_INET
if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
tristate 'CCITT X.25 Packet Layer (EXPERIMENTAL)' CONFIG_X25
tristate 'LAPB Data Link Driver (EXPERIMENTAL)' CONFIG_LAPB
tristate 'ANSI/IEEE 802.2 Data link layer protocol' CONFIG_LLC
if [ "$CONFIG_LLC" != "n" ]; then
# When NETBEUI is added the following line will be a tristate
define_bool CONFIG_LLC_UI y
fi
bool 'Frame Diverter (EXPERIMENTAL)' CONFIG_NET_DIVERT
if [ "$CONFIG_INET" = "y" ]; then
tristate 'Acorn Econet/AUN protocols (EXPERIMENTAL)' CONFIG_ECONET
......
......@@ -163,11 +163,8 @@ static void __aarp_send_query(struct aarp_entry *a)
eah->pa_dst_net = a->target_addr.s_net;
eah->pa_dst_node = a->target_addr.s_node;
/* Add ELAP headers and set target to the AARP multicast */
aarp_dl->datalink_header(aarp_dl, skb, aarp_eth_multicast);
/* Send it */
dev_queue_xmit(skb);
aarp_dl->request(aarp_dl, skb, aarp_eth_multicast);
/* Update the sending count */
a->xmit_count++;
}
......@@ -213,10 +210,8 @@ static void aarp_send_reply(struct net_device *dev, struct atalk_addr *us,
eah->pa_dst_net = them->s_net;
eah->pa_dst_node = them->s_node;
/* Add ELAP headers and set target to the AARP multicast */
aarp_dl->datalink_header(aarp_dl, skb, sha);
/* Send it */
dev_queue_xmit(skb);
aarp_dl->request(aarp_dl, skb, sha);
}
/*
......@@ -261,10 +256,8 @@ void aarp_send_probe(struct net_device *dev, struct atalk_addr *us)
eah->pa_dst_net = us->s_net;
eah->pa_dst_node = us->s_node;
/* Add ELAP headers and set target to the AARP multicast */
aarp_dl->datalink_header(aarp_dl, skb, aarp_eth_multicast);
/* Send it */
dev_queue_xmit(skb);
aarp_dl->request(aarp_dl, skb, aarp_eth_multicast);
}
/*
......@@ -602,8 +595,9 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb,
/* Do we have a resolved entry? */
if (sa->s_node == ATADDR_BCAST) {
ddp_dl->datalink_header(ddp_dl, skb, ddp_eth_multicast);
goto sendit;
/* Send it */
ddp_dl->request(ddp_dl, skb, ddp_eth_multicast);
goto sent;
}
spin_lock_bh(&aarp_lock);
......@@ -611,9 +605,9 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb,
if (a) { /* Return 1 and fill in the address */
a->expires_at = jiffies + (sysctl_aarp_expiry_time * 10);
ddp_dl->datalink_header(ddp_dl, skb, a->hwaddr);
ddp_dl->request(ddp_dl, skb, a->hwaddr);
spin_unlock_bh(&aarp_lock);
goto sendit;
goto sent;
}
/* Do we have an unresolved entry: This is the less common path */
......@@ -663,6 +657,7 @@ int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb,
if (skb->sk)
skb->priority = skb->sk->priority;
dev_queue_xmit(skb);
sent:
return 1;
}
......@@ -690,10 +685,7 @@ static void __aarp_resolved(struct aarp_entry **list, struct aarp_entry *a,
while ((skb = skb_dequeue(&a->packet_queue)) != NULL) {
a->expires_at = jiffies +
sysctl_aarp_expiry_time * 10;
ddp_dl->datalink_header(ddp_dl, skb, a->hwaddr);
if (skb->sk)
skb->priority = skb->sk->priority;
dev_queue_xmit(skb);
ddp_dl->request(ddp_dl, skb, a->hwaddr);
}
} else
list = &((*list)->next);
......@@ -989,7 +981,7 @@ void aarp_cleanup_module(void)
{
del_timer(&aarp_timer);
unregister_netdevice_notifier(&aarp_notifier);
unregister_snap_client(aarp_snap_id);
unregister_snap_client(aarp_dl);
}
#endif /* MODULE */
#ifdef CONFIG_PROC_FS
......
......@@ -1782,13 +1782,7 @@ static int atalk_sendmsg(struct socket *sock, struct msghdr *msg, int len,
SOCK_DEBUG(sk, "SK %p: Loop back.\n", sk);
/* loop back */
skb_orphan(skb);
ddp_dl->datalink_header(ddp_dl, skb, dev->dev_addr);
skb->mac.raw = skb->data;
skb->h.raw = skb->data + ddp_dl->header_length +
dev->hard_header_len;
skb_pull(skb, dev->hard_header_len);
skb_pull(skb, ddp_dl->header_length);
atalk_rcv(skb, dev, NULL);
ddp_dl->request(ddp_dl, skb, dev->dev_addr);
} else {
SOCK_DEBUG(sk, "SK %p: send out.\n", sk);
if (rt->flags & RTF_GATEWAY) {
......@@ -2040,7 +2034,7 @@ static void __exit atalk_exit(void)
unregister_netdevice_notifier(&ddp_notifier);
dev_remove_pack(&ltalk_packet_type);
dev_remove_pack(&ppptalk_packet_type);
unregister_snap_client(ddp_snap_id);
unregister_snap_client(ddp_dl);
sock_unregister(PF_APPLETALK);
}
module_exit(atalk_exit);
......
......@@ -2,8 +2,6 @@
# Makefile for the Linux networking core.
#
export-objs := ext8022.o
obj-y := sock.o skbuff.o iovec.o datagram.o scm.o
ifeq ($(CONFIG_SYSCTL),y)
......@@ -16,11 +14,6 @@ obj-$(CONFIG_FILTER) += filter.o
obj-$(CONFIG_NET) += dev.o dev_mcast.o dst.o neighbour.o rtnetlink.o utils.o
# See p8022 in net/802/Makefile for config options to check
ifneq ($(CONFIG_LLC)$(CONFIG_TR)$(CONFIG_IPX)$(CONFIG_ATALK),)
obj-y += ext8022.o
endif
obj-$(CONFIG_NETFILTER) += netfilter.o
obj-$(CONFIG_NET_DIVERT) += dv.o
obj-$(CONFIG_NET_PROFILE) += profile.o
......
/*
* (ext8022.c)
*
* Copyright (c) 1997 by Procom Technology, Inc.
* 2001 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
*
* This program can be redistributed or modified under the terms of the
* GNU General Public License as published by the Free Software Foundation.
* This program is distributed without any warranty or implied warranty
* of merchantability or fitness for a particular purpose.
*
* See the GNU General Public License for more details.
*/
#include <linux/config.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/brlock.h>
typedef int (*func_type)(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt);
static int llc_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *);
static func_type llc_sap_table[128];
static int llc_users;
static struct packet_type llc_packet_type = {
.type = __constant_htons(ETH_P_802_2),
.func = llc_rcv,
};
static struct packet_type llc_tr_packet_type = {
.type = __constant_htons(ETH_P_TR_802_2),
.func = llc_rcv,
};
static int llc_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt)
{
unsigned char n = (*(skb->h.raw)) >> 1;
br_read_lock(BR_LLC_LOCK);
if (llc_sap_table[n])
llc_sap_table[n](skb, dev, pt);
else
kfree_skb(skb);
br_read_unlock(BR_LLC_LOCK);
return 0;
}
void llc_register_sap(unsigned char sap, func_type rcvfunc)
{
sap >>= 1;
br_write_lock_bh(BR_LLC_LOCK);
llc_sap_table[sap] = rcvfunc;
if (!llc_users) {
dev_add_pack(&llc_packet_type);
dev_add_pack(&llc_tr_packet_type);
}
llc_users++;
br_write_unlock_bh(BR_LLC_LOCK);
}
void llc_unregister_sap(unsigned char sap)
{
sap >>= 1;
br_write_lock_bh(BR_LLC_LOCK);
llc_sap_table[sap] = NULL;
if (!--llc_users) {
dev_remove_pack(&llc_packet_type);
dev_remove_pack(&llc_tr_packet_type);
}
br_write_unlock_bh(BR_LLC_LOCK);
}
EXPORT_SYMBOL(llc_register_sap);
EXPORT_SYMBOL(llc_unregister_sap);
......@@ -2238,7 +2238,7 @@ MODULE_PARM(addr, "2i");
MODULE_PARM_DESC(addr, "The DECnet address of this machine: area,node");
#endif
static char banner[] __initdata = KERN_INFO "NET4: DECnet for Linux: V.2.4.15-pre5s (C) 1995-2001 Linux DECnet Project Team\n";
static char banner[] __initdata = KERN_INFO "NET4: DECnet for Linux: V.2.4.20-pre1s (C) 1995-2002 Linux DECnet Project Team\n";
static int __init decnet_init(void)
{
......
......@@ -35,6 +35,8 @@
* are numbered!
* Steve Whitehouse : Added return-to-sender functions. Added
* backlog congestion level return codes.
* Steve Whitehouse : Fixed bug where routes were set up with
* no ref count on net devices.
*
*/
......@@ -801,6 +803,8 @@ static int dn_route_output_slow(struct dst_entry **pprt, dn_address dst, dn_addr
rt->u.dst.neighbour = neigh;
rt->u.dst.dev = neigh ? neigh->dev : NULL;
if (rt->u.dst.dev)
dev_hold(rt->u.dst.dev);
rt->u.dst.lastuse = jiffies;
rt->u.dst.output = dn_output;
rt->u.dst.input = dn_rt_bug;
......@@ -978,6 +982,8 @@ static int dn_route_input_slow(struct sk_buff *skb)
rt->u.dst.neighbour = neigh;
rt->u.dst.dev = neigh ? neigh->dev : NULL;
if (rt->u.dst.dev)
dev_hold(rt->u.dst.dev);
rt->u.dst.lastuse = jiffies;
rt->u.dst.output = dnrt_output;
rt->u.dst.input = dnrt_input;
......
......@@ -4,8 +4,7 @@
#include <linux/mm.h>
#include <linux/in.h>
static void
pEII_datalink_header(struct datalink_proto *dl,
static int pEII_request(struct datalink_proto *dl,
struct sk_buff *skb, unsigned char *dest_node)
{
struct net_device *dev = skb->dev;
......@@ -13,6 +12,7 @@ pEII_datalink_header(struct datalink_proto *dl,
skb->protocol = htons (ETH_P_IPX);
if(dev->hard_header)
dev->hard_header(skb, dev, ETH_P_IPX, dest_node, NULL, skb->len);
return dev_queue_xmit(skb);
}
struct datalink_proto *
......@@ -22,10 +22,8 @@ make_EII_client(void)
proto = (struct datalink_proto *) kmalloc(sizeof(*proto), GFP_ATOMIC);
if (proto != NULL) {
proto->type_len = 0;
proto->header_length = 0;
proto->datalink_header = pEII_datalink_header;
proto->string_name = "EtherII";
proto->request = pEII_request;
}
return proto;
......
This diff is collapsed.
......@@ -777,10 +777,9 @@ static int ipxitf_send(struct ipx_interface *intrfc, struct sk_buff *skb,
/* set up data link and physical headers */
skb->dev = dev;
skb->protocol = htons(ETH_P_IPX);
dl->datalink_header(dl, skb, dest_node);
/* Send it out */
dev_queue_xmit(skb);
dl->request(dl, skb, dest_node);
out: return 0;
}
......@@ -2253,6 +2252,22 @@ drop: kfree_skb(skb);
out: return ret;
}
static int ipx_8022_indicate(struct llc_prim_if_block *prim)
{
int rc = 1;
static struct packet_type p8022_packet_type = {
.type = __constant_htons(ETH_P_802_2),
};
if (prim->prim == LLC_DATAUNIT_PRIM) {
struct sk_buff *skb = prim->data->udata.skb;
rc = ipx_rcv(skb, skb->dev, &p8022_packet_type);
}
return rc;
}
static int ipx_sendmsg(struct socket *sock, struct msghdr *msg, int len,
struct scm_cookie *scm)
{
......@@ -2545,7 +2560,7 @@ static int __init ipx_init(void)
else
printk(ipx_8023_err_msg);
p8022_datalink = register_8022_client(ipx_8022_type, ipx_rcv);
p8022_datalink = register_8022_client(ipx_8022_type, ipx_8022_indicate);
if (!p8022_datalink)
printk(ipx_llc_err_msg);
......@@ -2593,10 +2608,10 @@ static void __exit ipx_proto_finito(void)
unregister_netdevice_notifier(&ipx_dev_notifier);
unregister_snap_client(ipx_snap_id);
unregister_snap_client(pSNAP_datalink);
pSNAP_datalink = NULL;
unregister_8022_client(ipx_8022_type);
unregister_8022_client(p8022_datalink);
p8022_datalink = NULL;
dev_remove_pack(&ipx_8023_packet_type);
......
......@@ -61,15 +61,18 @@ int llc_conn_ac_clear_remote_busy(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_conn_ind(struct sock *sk, struct llc_conn_state_ev *ev)
{
int rc = 1;
u8 dsap;
struct sk_buff *skb = ev->data.pdu.skb;
union llc_u_prim_data *prim_data = llc_ind_prim.data;
struct llc_prim_if_block *prim = &llc_ind_prim;
struct llc_sap *sap;
struct llc_opt *llc = llc_sk(sk);
llc_pdu_decode_dsap(skb, &prim_data->conn.daddr.lsap);
sap = llc_sap_find(prim_data->conn.daddr.lsap);
llc_pdu_decode_dsap(skb, &dsap);
sap = llc_sap_find(dsap);
if (sap) {
struct llc_prim_if_block *prim = &sap->llc_ind_prim;
union llc_u_prim_data *prim_data = prim->data;
struct llc_opt *llc = llc_sk(sk);
prim_data->conn.daddr.lsap = dsap;
llc_pdu_decode_sa(skb, llc->daddr.mac);
llc_pdu_decode_da(skb, llc->laddr.mac);
llc->dev = skb->dev;
......@@ -90,14 +93,11 @@ int llc_conn_ac_conn_ind(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_conn_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
{
union llc_u_prim_data *prim_data = llc_cfm_prim.data;
struct sk_buff *skb = ev->data.pdu.skb;
/* FIXME: wtf, this is global, so the whole thing is really
* non reentrant...
*/
struct llc_prim_if_block *prim = &llc_cfm_prim;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_cfm_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->conn.sk = sk;
prim_data->conn.pri = 0;
......@@ -106,7 +106,7 @@ int llc_conn_ac_conn_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
if (skb)
prim_data->conn.dev = skb->dev;
else
printk(KERN_ERR __FUNCTION__ "ev->data.pdu.skb == NULL\n");
printk(KERN_ERR "%s: ev->data.pdu.skb == NULL\n", __FUNCTION__);
prim->data = prim_data;
prim->prim = LLC_CONN_PRIM;
prim->sap = sap;
......@@ -118,17 +118,19 @@ int llc_conn_ac_conn_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
static int llc_conn_ac_data_confirm(struct sock *sk,
struct llc_conn_state_ev *ev)
{
struct llc_prim_if_block *prim = &llc_cfm_prim;
union llc_u_prim_data *prim_data = llc_cfm_prim.data;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_cfm_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->data.sk = sk;
prim_data->data.pri = 0;
prim_data->data.link = llc_sk(sk)->link;
prim_data->data.link = llc->link;
prim_data->data.status = LLC_STATUS_RECEIVED;
prim_data->data.skb = NULL;
prim->data = prim_data;
prim->prim = LLC_DATA_PRIM;
prim->sap = llc_sk(sk)->sap;
prim->sap = sap;
ev->flag = 1;
ev->cfm_prim = prim;
return 0;
......@@ -144,12 +146,9 @@ int llc_conn_ac_disc_ind(struct sock *sk, struct llc_conn_state_ev *ev)
{
u8 reason = 0;
int rc = 1;
union llc_u_prim_data *prim_data = llc_ind_prim.data;
struct llc_prim_if_block *prim = &llc_ind_prim;
if (ev->type == LLC_CONN_EV_TYPE_PDU) {
struct llc_pdu_un *pdu =
(struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
if (!LLC_PDU_IS_RSP(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) &&
......@@ -170,12 +169,17 @@ int llc_conn_ac_disc_ind(struct sock *sk, struct llc_conn_state_ev *ev)
rc = 1;
}
if (!rc) {
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_ind_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->disc.sk = sk;
prim_data->disc.reason = reason;
prim_data->disc.link = llc_sk(sk)->link;
prim_data->disc.link = llc->link;
prim->data = prim_data;
prim->prim = LLC_DISC_PRIM;
prim->sap = llc_sk(sk)->sap;
prim->sap = llc->sap;
ev->flag = 1;
ev->ind_prim = prim;
}
......@@ -184,15 +188,17 @@ int llc_conn_ac_disc_ind(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_disc_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
{
union llc_u_prim_data *prim_data = llc_cfm_prim.data;
struct llc_prim_if_block *prim = &llc_cfm_prim;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_cfm_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->disc.sk = sk;
prim_data->disc.reason = ev->status;
prim_data->disc.link = llc_sk(sk)->link;
prim_data->disc.link = llc->link;
prim->data = prim_data;
prim->prim = LLC_DISC_PRIM;
prim->sap = llc_sk(sk)->sap;
prim->sap = sap;
ev->flag = 1;
ev->cfm_prim = prim;
return 0;
......@@ -202,9 +208,7 @@ int llc_conn_ac_rst_ind(struct sock *sk, struct llc_conn_state_ev *ev)
{
u8 reason = 0;
int rc = 1;
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
union llc_u_prim_data *prim_data = llc_ind_prim.data;
struct llc_prim_if_block *prim = &llc_ind_prim;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
struct llc_opt *llc = llc_sk(sk);
switch (ev->type) {
......@@ -237,12 +241,16 @@ int llc_conn_ac_rst_ind(struct sock *sk, struct llc_conn_state_ev *ev)
break;
}
if (!rc) {
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_ind_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->res.sk = sk;
prim_data->res.reason = reason;
prim_data->res.link = llc->link;
prim->data = prim_data;
prim->prim = LLC_RESET_PRIM;
prim->sap = llc->sap;
prim->sap = sap;
ev->flag = 1;
ev->ind_prim = prim;
}
......@@ -251,14 +259,16 @@ int llc_conn_ac_rst_ind(struct sock *sk, struct llc_conn_state_ev *ev)
int llc_conn_ac_rst_confirm(struct sock *sk, struct llc_conn_state_ev *ev)
{
union llc_u_prim_data *prim_data = llc_cfm_prim.data;
struct llc_prim_if_block *prim = &llc_cfm_prim;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_cfm_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->res.sk = sk;
prim_data->res.link = llc_sk(sk)->link;
prim_data->res.link = llc->link;
prim->data = prim_data;
prim->prim = LLC_RESET_PRIM;
prim->sap = llc_sk(sk)->sap;
prim->sap = sap;
ev->flag = 1;
ev->cfm_prim = prim;
return 0;
......
This diff is collapsed.
......@@ -82,7 +82,7 @@ int llc_conn_send_ev(struct sock *sk, struct llc_conn_state_ev *ev)
/* check if the connection was freed by the state machine by
* means of llc_conn_disc */
if (rc == 2) {
printk(KERN_INFO __FUNCTION__ ": rc == 2\n");
printk(KERN_INFO "%s: rc == 2\n", __FUNCTION__);
rc = -ECONNABORTED;
goto out;
}
......@@ -134,16 +134,18 @@ void llc_conn_send_pdu(struct sock *sk, struct sk_buff *skb)
void llc_conn_rtn_pdu(struct sock *sk, struct sk_buff *skb,
struct llc_conn_state_ev *ev)
{
struct llc_prim_if_block *prim = &llc_ind_prim;
union llc_u_prim_data *prim_data = llc_ind_prim.data;
struct llc_opt *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap;
struct llc_prim_if_block *prim = &sap->llc_ind_prim;
union llc_u_prim_data *prim_data = prim->data;
prim_data->data.sk = sk;
prim_data->data.pri = 0;
prim_data->data.skb = skb;
prim_data->data.link = llc_sk(sk)->link;
prim_data->data.link = llc->link;
prim->data = prim_data;
prim->prim = LLC_DATA_PRIM;
prim->sap = llc_sk(sk)->sap;
prim->sap = sap;
ev->flag = 1;
/* saving prepd prim in event for future use in llc_conn_send_ev */
ev->ind_prim = prim;
......
......@@ -56,7 +56,7 @@ int llc_stat_ev_ack_tmr_exp_eq_retry_cnt_max_retry(struct llc_station *station,
int llc_stat_ev_rx_null_dsap_xid_c(struct llc_station *station,
struct llc_station_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_STATION_EV_TYPE_PDU &&
!LLC_PDU_IS_CMD(pdu) && /* command PDU */
......@@ -68,7 +68,7 @@ int llc_stat_ev_rx_null_dsap_xid_c(struct llc_station *station,
int llc_stat_ev_rx_null_dsap_0_xid_r_xid_r_cnt_eq(struct llc_station *station,
struct llc_station_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_STATION_EV_TYPE_PDU &&
!LLC_PDU_IS_RSP(pdu) && /* response PDU */
......@@ -81,7 +81,7 @@ int llc_stat_ev_rx_null_dsap_0_xid_r_xid_r_cnt_eq(struct llc_station *station,
int llc_stat_ev_rx_null_dsap_1_xid_r_xid_r_cnt_eq(struct llc_station *station,
struct llc_station_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_STATION_EV_TYPE_PDU &&
!LLC_PDU_IS_RSP(pdu) && /* response PDU */
......@@ -94,7 +94,7 @@ int llc_stat_ev_rx_null_dsap_1_xid_r_xid_r_cnt_eq(struct llc_station *station,
int llc_stat_ev_rx_null_dsap_test_c(struct llc_station *station,
struct llc_station_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_STATION_EV_TYPE_PDU &&
!LLC_PDU_IS_CMD(pdu) && /* command PDU */
......
......@@ -41,12 +41,6 @@ static int llc_conn_rsp_handler(struct llc_prim_if_block *prim);
static int llc_rst_rsp_handler(struct llc_prim_if_block *prim);
static int llc_no_rsp_handler(struct llc_prim_if_block *prim);
extern void llc_register_sap(unsigned char sap,
int (*rcvfunc)(struct sk_buff *skb,
struct net_device *dev,
struct packet_type *pt));
extern void llc_unregister_sap(unsigned char sap);
/* table of request handler functions */
static llc_prim_call_t llc_req_prim[LLC_NBR_PRIMITIVES] = {
[LLC_DATAUNIT_PRIM] = llc_unitdata_req_handler,
......@@ -105,7 +99,6 @@ struct llc_sap *llc_sap_open(llc_prim_call_t nw_indicate,
sap->parent_station = llc_station_get();
/* initialized SAP; add it to list of SAPs this station manages */
llc_sap_save(sap);
llc_register_sap(lsap, mac_indicate);
out:
return sap;
err:
......@@ -122,7 +115,6 @@ struct llc_sap *llc_sap_open(llc_prim_call_t nw_indicate,
*/
void llc_sap_close(struct llc_sap *sap)
{
llc_unregister_sap(sap->laddr.lsap);
llc_free_sap(sap);
MOD_DEC_USE_COUNT;
}
......@@ -141,7 +133,7 @@ static int llc_sap_req(struct llc_prim_if_block *prim)
int rc = 1;
if (prim->prim > 8 || prim->prim == 6) {
printk(KERN_ERR __FUNCTION__ ": invalid primitive %d\n",
printk(KERN_ERR "%s: invalid primitive %d\n", __FUNCTION__,
prim->prim);
goto out;
}
......@@ -338,7 +330,7 @@ static int llc_conn_req_handler(struct llc_prim_if_block *prim)
memcpy(laddr.mac, sdev->dev_addr, sizeof(laddr.mac));
laddr.lsap = prim->data->conn.saddr.lsap;
memcpy(daddr.mac, ddev->dev_addr, sizeof(daddr.mac));
memcpy(daddr.mac, prim->data->conn.daddr.mac, sizeof(daddr.mac));
daddr.lsap = prim->data->conn.daddr.lsap;
sk = llc_find_sock(sap, &daddr, &laddr);
if (sk) {
......
......@@ -46,7 +46,7 @@ int mac_send_pdu(struct sk_buff *skb)
int pri = GFP_ATOMIC, rc = -1;
if (!skb->dev) {
printk(KERN_ERR __FUNCTION__ ": skb->dev == NULL!");
printk(KERN_ERR "%s: skb->dev == NULL!", __FUNCTION__);
goto out;
}
if (skb->sk)
......@@ -83,27 +83,30 @@ int mac_indicate(struct sk_buff *skb, struct net_device *dev,
* receives, do not try to analyse it.
*/
if (skb->pkt_type == PACKET_OTHERHOST) {
printk(KERN_INFO __FUNCTION__ ": PACKET_OTHERHOST\n");
printk(KERN_INFO "%s: PACKET_OTHERHOST\n", __FUNCTION__);
goto drop;
}
skb = skb_share_check(skb, GFP_ATOMIC);
if (!skb)
goto out;
fix_up_incoming_skb(skb);
pdu = (struct llc_pdu_sn *)skb->nh.raw;
pdu = llc_pdu_sn_hdr(skb);
if (!pdu->dsap) { /* NULL DSAP, refer to station */
llc_pdu_router(NULL, NULL, skb, 0);
if (llc_pdu_router(NULL, NULL, skb, 0))
goto drop;
goto out;
}
sap = llc_sap_find(pdu->dsap);
if (!sap) /* unknown SAP */
goto drop;
llc_decode_pdu_type(skb, &dest);
if (dest == LLC_DEST_SAP) /* type 1 services */
llc_pdu_router(sap, NULL, skb, LLC_TYPE_1);
else if (dest == LLC_DEST_CONN) {
if (dest == LLC_DEST_SAP) { /* type 1 services */
if (llc_pdu_router(sap, NULL, skb, LLC_TYPE_1))
goto drop;
} else if (dest == LLC_DEST_CONN) {
struct llc_addr saddr, daddr;
struct sock *sk;
int rc;
llc_pdu_decode_sa(skb, saddr.mac);
llc_pdu_decode_ssap(skb, &saddr.lsap);
......@@ -134,14 +137,17 @@ int mac_indicate(struct sk_buff *skb, struct net_device *dev,
* in the llc_req_prim (llc_data_req_handler, etc) and
* add the request to the backlog, well see...
*/
llc_pdu_router(llc_sk(sk)->sap, sk, skb, LLC_TYPE_2);
bh_unlock_sock(sk);
rc = llc_pdu_router(llc_sk(sk)->sap, sk, skb,
LLC_TYPE_2);
} else {
skb->cb[0] = LLC_PACKET;
sk_add_backlog(sk, skb);
bh_unlock_sock(sk);
rc = 0;
}
bh_unlock_sock(sk);
sock_put(sk);
if (rc)
goto drop;
} else /* unknown or not supported pdu */
goto drop;
out:
......@@ -196,7 +202,7 @@ static void fix_up_incoming_skb(struct sk_buff *skb)
int llc_pdu_router(struct llc_sap *sap, struct sock* sk,
struct sk_buff *skb, u8 type)
{
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)skb->nh.raw;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
int rc = 0;
if (!pdu->dsap) {
......@@ -208,7 +214,8 @@ int llc_pdu_router(struct llc_sap *sap, struct sock* sk,
stat_ev->data.pdu.skb = skb;
stat_ev->data.pdu.reason = 0;
llc_station_send_ev(station, stat_ev);
}
} else
rc = -ENOMEM;
} else if (type == LLC_TYPE_1) {
struct llc_sap_state_ev *sap_ev = llc_sap_alloc_ev(sap);
......@@ -217,7 +224,8 @@ int llc_pdu_router(struct llc_sap *sap, struct sock* sk,
sap_ev->data.pdu.skb = skb;
sap_ev->data.pdu.reason = 0;
llc_sap_send_ev(sap, sap_ev);
}
} else
rc = -ENOMEM;
} else if (type == LLC_TYPE_2) {
struct llc_conn_state_ev *conn_ev = llc_conn_alloc_ev(sk);
struct llc_opt *llc = llc_sk(sk);
......@@ -229,8 +237,10 @@ int llc_pdu_router(struct llc_sap *sap, struct sock* sk,
conn_ev->data.pdu.skb = skb;
conn_ev->data.pdu.reason = 0;
rc = llc_conn_send_ev(sk, conn_ev);
}
}
} else
rc = -ENOMEM;
} else
rc = -EINVAL;
return rc;
}
......
......@@ -50,15 +50,7 @@ static struct llc_station_state_trans *
struct llc_station_state_ev *ev);
static int llc_rtn_all_conns(struct llc_sap *sap);
extern void llc_register_sap(unsigned char sap,
int (*rcvfunc)(struct sk_buff *skb,
struct net_device *dev,
struct packet_type *pt));
extern void llc_unregister_sap(unsigned char sap);
static struct llc_station llc_main_station; /* only one of its kind */
struct llc_prim_if_block llc_ind_prim, llc_cfm_prim;
static union llc_u_prim_data llc_ind_data_prim, llc_cfm_data_prim;
/**
* llc_sap_alloc - allocates and initializes sap.
......@@ -76,6 +68,8 @@ struct llc_sap *llc_sap_alloc(void)
spin_lock_init(&sap->sk_list.lock);
INIT_LIST_HEAD(&sap->sk_list.list);
skb_queue_head_init(&sap->mac_pdu_q);
sap->llc_ind_prim.data = &sap->llc_ind_data_prim;
sap->llc_cfm_prim.data = &sap->llc_cfm_data_prim;
}
return sap;
}
......@@ -238,7 +232,7 @@ void __llc_sock_free(struct sock *sk, u8 free)
/* stop all (possibly) running timers */
llc_conn_ac_stop_all_timers(sk, NULL);
/* handle return of frames on lists */
printk(KERN_INFO __FUNCTION__ ": unackq=%d, txq=%d\n",
printk(KERN_INFO "%s: unackq=%d, txq=%d\n", __FUNCTION__,
skb_queue_len(&llc->pdu_unack_q),
skb_queue_len(&sk->write_queue));
skb_queue_purge(&sk->write_queue);
......@@ -580,6 +574,18 @@ static int llc_proc_get_info(char *bf, char **start, off_t offset, int length)
return len;
}
static struct packet_type llc_packet_type = {
.type = __constant_htons(ETH_P_802_2),
.func = mac_indicate,
.data = (void *)1,
};
static struct packet_type llc_tr_packet_type = {
.type = __constant_htons(ETH_P_TR_802_2),
.func = mac_indicate,
.data = (void *)1,
};
static char llc_banner[] __initdata =
KERN_INFO "LLC 2.0 by Procom, 1997, Arnaldo C. Melo, 2001\n"
KERN_INFO "NET4.0 IEEE 802.2 extended support\n";
......@@ -612,12 +618,10 @@ static int __init llc_init(void)
ev->type = LLC_STATION_EV_TYPE_SIMPLE;
ev->data.a.ev = LLC_STATION_EV_ENABLE_WITHOUT_DUP_ADDR_CHECK;
rc = llc_station_next_state(&llc_main_station, ev);
llc_ind_prim.data = &llc_ind_data_prim;
llc_cfm_prim.data = &llc_cfm_data_prim;
proc_net_create("802.2", 0, llc_proc_get_info);
/* initialize the station component */
llc_register_sap(0, mac_indicate);
llc_ui_init();
dev_add_pack(&llc_packet_type);
dev_add_pack(&llc_tr_packet_type);
out:
return rc;
err:
......@@ -629,7 +633,8 @@ static int __init llc_init(void)
static void __exit llc_exit(void)
{
llc_ui_exit();
llc_unregister_sap(0);
dev_remove_pack(&llc_packet_type);
dev_remove_pack(&llc_tr_packet_type);
proc_net_remove("802.2");
}
......
This diff is collapsed.
......@@ -28,7 +28,7 @@ int llc_sap_ev_activation_req(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_ui(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_CMD(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) &&
......@@ -52,7 +52,7 @@ int llc_sap_ev_xid_req(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_xid_c(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_CMD(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) &&
......@@ -61,7 +61,7 @@ int llc_sap_ev_rx_xid_c(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_xid_r(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_RSP(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) &&
......@@ -77,7 +77,7 @@ int llc_sap_ev_test_req(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_test_c(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_CMD(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) &&
......@@ -86,7 +86,7 @@ int llc_sap_ev_rx_test_c(struct llc_sap *sap, struct llc_sap_state_ev *ev)
int llc_sap_ev_rx_test_r(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{
struct llc_pdu_un *pdu = (struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
struct llc_pdu_un *pdu = llc_pdu_un_hdr(ev->data.pdu.skb);
return ev->type == LLC_SAP_EV_TYPE_PDU && !LLC_PDU_IS_RSP(pdu) &&
!LLC_PDU_TYPE_IS_U(pdu) &&
......
......@@ -89,15 +89,10 @@ struct llc_sap_state_ev *llc_sap_alloc_ev(struct llc_sap *sap)
*/
void llc_sap_send_ev(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{
struct llc_prim_if_block *prim;
u8 flag;
llc_sap_next_state(sap, ev);
flag = ev->ind_cfm_flag;
prim = ev->prim;
if (flag == LLC_IND) {
if (ev->ind_cfm_flag == LLC_IND) {
skb_get(ev->data.pdu.skb);
sap->ind(prim);
sap->ind(ev->prim);
}
llc_sap_free_ev(sap, ev);
}
......@@ -112,8 +107,8 @@ void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb,
struct llc_sap_state_ev *ev)
{
struct llc_pdu_un *pdu;
struct llc_prim_if_block *prim = &llc_ind_prim;
union llc_u_prim_data *prim_data = llc_ind_prim.data;
struct llc_prim_if_block *prim = &sap->llc_ind_prim;
union llc_u_prim_data *prim_data = prim->data;
u8 lfb;
llc_pdu_decode_sa(skb, prim_data->udata.saddr.mac);
......@@ -122,7 +117,7 @@ void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb,
llc_pdu_decode_ssap(skb, &prim_data->udata.saddr.lsap);
prim_data->udata.pri = 0;
prim_data->udata.skb = skb;
pdu = (struct llc_pdu_un *)skb->nh.raw;
pdu = llc_pdu_un_hdr(skb);
switch (LLC_U_PDU_RSP(pdu)) {
case LLC_1_PDU_CMD_TEST:
prim->prim = LLC_TEST_PRIM;
......@@ -169,13 +164,8 @@ void llc_sap_send_pdu(struct llc_sap *sap, struct sk_buff *skb)
*/
static void llc_sap_free_ev(struct llc_sap *sap, struct llc_sap_state_ev *ev)
{
if (ev->type == LLC_SAP_EV_TYPE_PDU) {
struct llc_pdu_un *pdu =
(struct llc_pdu_un *)ev->data.pdu.skb->nh.raw;
if (LLC_U_PDU_CMD(pdu) != LLC_1_PDU_CMD_UI)
kfree_skb(ev->data.pdu.skb);
}
if (ev->type == LLC_SAP_EV_TYPE_PDU)
kfree_skb(ev->data.pdu.skb);
kfree(ev);
}
......
......@@ -43,8 +43,6 @@
#include <linux/rtnetlink.h>
#include <linux/init.h>
#define dprintk(format, a...) printk(KERN_INFO __FUNCTION__ ": " format, ##a)
/* remember: uninitialized global data is zeroed because its in .bss */
static u16 llc_ui_sap_last_autoport = LLC_SAP_DYN_START;
static u16 llc_ui_sap_link_no_max[256];
......@@ -527,8 +525,6 @@ static int llc_ui_release(struct socket *sock)
llc_ui_remove_socket(sk);
if (llc_ui->sap && !llc_ui_find_sap(llc_ui->sap->laddr.lsap))
llc_sap_close(llc_ui->sap);
dprintk("rxq=%d, txq=%d\n", skb_queue_len(&sk->receive_queue),
skb_queue_len(&sk->write_queue));
sock_orphan(sk);
sock->sk = NULL;
if (!atomic_read(&sk->wmem_alloc) &&
......@@ -1416,10 +1412,8 @@ static void llc_ui_ind_conn(struct llc_prim_if_block *prim)
llc_sk(prim_data->sk)->laddr.lsap = prim->sap->laddr.lsap;
sk = llc_ui_find_sk_by_addr(&llc_sk(prim_data->sk)->laddr,
&prim_data->saddr, prim_data->dev);
if (!sk) {
dprintk("llc_ui_find_sk_by_addr failed\n");
if (!sk)
goto out;
}
if (sk->type != SOCK_STREAM || sk->state != TCP_LISTEN)
goto out_put;
if (prim->data->conn.status)
......@@ -1469,10 +1463,8 @@ static void llc_ui_ind_data(struct llc_prim_if_block *prim)
memcpy(llc_ui->sllc_smac, llc_sk(prim_data->sk)->daddr.mac,
IFHWADDRLEN);
/* queue skb to the user. */
if (sock_queue_rcv_skb(sk, skb)) {
dprintk("sock_queue_rcv_skb failed!\n");
if (sock_queue_rcv_skb(sk, skb))
kfree_skb(skb);
}
out_put:
sock_put(sk);
out:;
......@@ -1547,13 +1539,11 @@ static void llc_ui_conf_conn(struct llc_prim_if_block *prim)
{
struct llc_prim_conn *prim_data = &prim->data->conn;
struct llc_opt *llc_core = llc_sk(prim_data->sk);
struct llc_ui_opt *llc_ui = llc_ui_sk(prim_data->sk);
struct sock* sk = llc_core->handler;
struct llc_ui_opt *llc_ui = llc_ui_sk(sk);
if (!sk) {
dprintk("llc_core->handler == NULL!\n");
if (!sk)
goto out;
}
sock_hold(sk);
if (sk->type != SOCK_STREAM || sk->state != TCP_SYN_SENT)
goto out_put;
......@@ -1562,8 +1552,6 @@ static void llc_ui_conf_conn(struct llc_prim_if_block *prim)
sk->state = TCP_ESTABLISHED;
llc_ui->core_sk = prim_data->sk;
} else {
dprintk("prim->data->conn.status = %d\n",
prim->data->conn.status);
sk->socket->state = SS_UNCONNECTED;
sk->state = TCP_CLOSE;
llc_ui->core_sk = NULL;
......@@ -1633,7 +1621,7 @@ static int llc_ui_confirm(struct llc_prim_if_block *prim)
llc_ui_conf_disc(prim); break;
case LLC_RESET_PRIM: break;
default:
printk(KERN_ERR __FUNCTION__ ": unknown prim %d\n",
printk(KERN_ERR "%s: unknown prim %d\n", __FUNCTION__,
prim->prim);
break;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment