make psnap and p8022 use the new LLC stack

. kill BR_LLC_LOCK, not needed anymore
. kill net/core/ext8022.c, not needed anymore as all
  UI 802.2 protocols now use the new LLC stack
. use struct list_head in datalink_proto (only needed by psnap)
. make IPX and Appletalk use datalink_proto->request
. make CONFIG_ATALK and CONFIG_IPX dependent on CONFIG_LLC
. fix __FUNCTION__ usage in LLC 
parent c4265b8b
......@@ -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
......@@ -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
};
......
......@@ -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
#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);
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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,7 +83,7 @@ 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);
......@@ -92,18 +92,21 @@ int mac_indicate(struct sk_buff *skb, struct net_device *dev,
fix_up_incoming_skb(skb);
pdu = (struct llc_pdu_sn *)skb->nh.raw;
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:
......@@ -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,12 +50,6 @@ 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;
......@@ -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";
......@@ -615,9 +621,9 @@ static int __init llc_init(void)
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 +635,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");
}
......
......@@ -169,13 +169,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:;
......@@ -1550,10 +1542,8 @@ static void llc_ui_conf_conn(struct llc_prim_if_block *prim)
struct llc_ui_opt *llc_ui = llc_ui_sk(prim_data->sk);
struct sock* sk = llc_core->handler;
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