aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/bnx2.c32
-rw-r--r--include/linux/atmlec.h119
-rw-r--r--include/linux/audit.h11
-rw-r--r--include/linux/pci_ids.h1
-rw-r--r--include/net/cipso_ipv4.h4
-rw-r--r--include/net/netlabel.h8
-rw-r--r--net/atm/lec.c3161
-rw-r--r--net/atm/lec.h172
-rw-r--r--net/atm/lec_arpc.h146
-rw-r--r--net/ipv4/cipso_ipv4.c4
-rw-r--r--net/netlabel/netlabel_cipso_v4.c48
-rw-r--r--net/netlabel/netlabel_domainhash.c82
-rw-r--r--net/netlabel/netlabel_domainhash.h8
-rw-r--r--net/netlabel/netlabel_mgmt.c27
-rw-r--r--net/netlabel/netlabel_unlabeled.c34
-rw-r--r--net/netlabel/netlabel_user.c66
-rw-r--r--net/netlabel/netlabel_user.h16
-rw-r--r--net/sctp/input.c8
-rw-r--r--net/sctp/output.c10
-rw-r--r--net/sctp/outqueue.c3
-rw-r--r--net/sctp/sm_make_chunk.c10
-rw-r--r--net/sctp/socket.c4
22 files changed, 1999 insertions, 1975 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 7fcf015021ec..6b4edb63c4c4 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -56,8 +56,8 @@
56 56
57#define DRV_MODULE_NAME "bnx2" 57#define DRV_MODULE_NAME "bnx2"
58#define PFX DRV_MODULE_NAME ": " 58#define PFX DRV_MODULE_NAME ": "
59#define DRV_MODULE_VERSION "1.4.44" 59#define DRV_MODULE_VERSION "1.4.45"
60#define DRV_MODULE_RELDATE "August 10, 2006" 60#define DRV_MODULE_RELDATE "September 29, 2006"
61 61
62#define RUN_AT(x) (jiffies + (x)) 62#define RUN_AT(x) (jiffies + (x))
63 63
@@ -5805,6 +5805,34 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5805 bp->cmd_ticks_int = bp->cmd_ticks; 5805 bp->cmd_ticks_int = bp->cmd_ticks;
5806 } 5806 }
5807 5807
5808 /* Disable MSI on 5706 if AMD 8132 bridge is found.
5809 *
5810 * MSI is defined to be 32-bit write. The 5706 does 64-bit MSI writes
5811 * with byte enables disabled on the unused 32-bit word. This is legal
5812 * but causes problems on the AMD 8132 which will eventually stop
5813 * responding after a while.
5814 *
5815 * AMD believes this incompatibility is unique to the 5706, and
5816 * prefers to locally disable MSI rather than globally disabling it
5817 * using pci_msi_quirk.
5818 */
5819 if (CHIP_NUM(bp) == CHIP_NUM_5706 && disable_msi == 0) {
5820 struct pci_dev *amd_8132 = NULL;
5821
5822 while ((amd_8132 = pci_get_device(PCI_VENDOR_ID_AMD,
5823 PCI_DEVICE_ID_AMD_8132_BRIDGE,
5824 amd_8132))) {
5825 u8 rev;
5826
5827 pci_read_config_byte(amd_8132, PCI_REVISION_ID, &rev);
5828 if (rev >= 0x10 && rev <= 0x13) {
5829 disable_msi = 1;
5830 pci_dev_put(amd_8132);
5831 break;
5832 }
5833 }
5834 }
5835
5808 bp->autoneg = AUTONEG_SPEED | AUTONEG_FLOW_CTRL; 5836 bp->autoneg = AUTONEG_SPEED | AUTONEG_FLOW_CTRL;
5809 bp->req_line_speed = 0; 5837 bp->req_line_speed = 0;
5810 if (bp->phy_flags & PHY_SERDES_FLAG) { 5838 if (bp->phy_flags & PHY_SERDES_FLAG) {
diff --git a/include/linux/atmlec.h b/include/linux/atmlec.h
index f267f2442766..6f5a1bab8f50 100644
--- a/include/linux/atmlec.h
+++ b/include/linux/atmlec.h
@@ -1,9 +1,7 @@
1/* 1/*
2 * 2 * ATM Lan Emulation Daemon driver interface
3 * ATM Lan Emulation Daemon vs. driver interface
4 *
5 * mkiiskila@yahoo.com
6 * 3 *
4 * Marko Kiiskila <mkiiskila@yahoo.com>
7 */ 5 */
8 6
9#ifndef _ATMLEC_H_ 7#ifndef _ATMLEC_H_
@@ -13,76 +11,87 @@
13#include <linux/atmioc.h> 11#include <linux/atmioc.h>
14#include <linux/atm.h> 12#include <linux/atm.h>
15#include <linux/if_ether.h> 13#include <linux/if_ether.h>
14
16/* ATM lec daemon control socket */ 15/* ATM lec daemon control socket */
17#define ATMLEC_CTRL _IO('a',ATMIOC_LANE) 16#define ATMLEC_CTRL _IO('a', ATMIOC_LANE)
18#define ATMLEC_DATA _IO('a',ATMIOC_LANE+1) 17#define ATMLEC_DATA _IO('a', ATMIOC_LANE+1)
19#define ATMLEC_MCAST _IO('a',ATMIOC_LANE+2) 18#define ATMLEC_MCAST _IO('a', ATMIOC_LANE+2)
20 19
21/* Maximum number of LEC interfaces (tweakable) */ 20/* Maximum number of LEC interfaces (tweakable) */
22#define MAX_LEC_ITF 48 21#define MAX_LEC_ITF 48
23 22
24/* From the total of MAX_LEC_ITF, last NUM_TR_DEVS are reserved for Token Ring. 23/*
24 * From the total of MAX_LEC_ITF, last NUM_TR_DEVS are reserved for Token Ring.
25 * E.g. if MAX_LEC_ITF = 48 and NUM_TR_DEVS = 8, then lec0-lec39 are for 25 * E.g. if MAX_LEC_ITF = 48 and NUM_TR_DEVS = 8, then lec0-lec39 are for
26 * Ethernet ELANs and lec40-lec47 are for Token Ring ELANS. 26 * Ethernet ELANs and lec40-lec47 are for Token Ring ELANS.
27 */ 27 */
28#define NUM_TR_DEVS 8 28#define NUM_TR_DEVS 8
29 29
30typedef enum { 30typedef enum {
31 l_set_mac_addr, l_del_mac_addr, 31 l_set_mac_addr,
32 l_svc_setup, 32 l_del_mac_addr,
33 l_addr_delete, l_topology_change, 33 l_svc_setup,
34 l_flush_complete, l_arp_update, 34 l_addr_delete,
35 l_narp_req, /* LANE2 mandates the use of this */ 35 l_topology_change,
36 l_config, l_flush_tran_id, 36 l_flush_complete,
37 l_set_lecid, l_arp_xmt, 37 l_arp_update,
38 l_rdesc_arp_xmt, 38 l_narp_req, /* LANE2 mandates the use of this */
39 l_associate_req, 39 l_config,
40 l_should_bridge /* should we bridge this MAC? */ 40 l_flush_tran_id,
41 l_set_lecid,
42 l_arp_xmt,
43 l_rdesc_arp_xmt,
44 l_associate_req,
45 l_should_bridge /* should we bridge this MAC? */
41} atmlec_msg_type; 46} atmlec_msg_type;
42 47
43#define ATMLEC_MSG_TYPE_MAX l_should_bridge 48#define ATMLEC_MSG_TYPE_MAX l_should_bridge
44 49
45struct atmlec_config_msg { 50struct atmlec_config_msg {
46 unsigned int maximum_unknown_frame_count; 51 unsigned int maximum_unknown_frame_count;
47 unsigned int max_unknown_frame_time; 52 unsigned int max_unknown_frame_time;
48 unsigned short max_retry_count; 53 unsigned short max_retry_count;
49 unsigned int aging_time; 54 unsigned int aging_time;
50 unsigned int forward_delay_time; 55 unsigned int forward_delay_time;
51 unsigned int arp_response_time; 56 unsigned int arp_response_time;
52 unsigned int flush_timeout; 57 unsigned int flush_timeout;
53 unsigned int path_switching_delay; 58 unsigned int path_switching_delay;
54 unsigned int lane_version; /* LANE2: 1 for LANEv1, 2 for LANEv2 */ 59 unsigned int lane_version; /* LANE2: 1 for LANEv1, 2 for LANEv2 */
55 int mtu; 60 int mtu;
56 int is_proxy; 61 int is_proxy;
57}; 62};
58 63
59struct atmlec_msg { 64struct atmlec_msg {
60 atmlec_msg_type type; 65 atmlec_msg_type type;
61 int sizeoftlvs; /* LANE2: if != 0, tlvs follow */ 66 int sizeoftlvs; /* LANE2: if != 0, tlvs follow */
62 union { 67 union {
63 struct { 68 struct {
64 unsigned char mac_addr[ETH_ALEN]; 69 unsigned char mac_addr[ETH_ALEN];
65 unsigned char atm_addr[ATM_ESA_LEN]; 70 unsigned char atm_addr[ATM_ESA_LEN];
66 unsigned int flag;/* Topology_change flag, 71 unsigned int flag; /*
67 remoteflag, permanent flag, 72 * Topology_change flag,
68 lecid, transaction id */ 73 * remoteflag, permanent flag,
69 unsigned int targetless_le_arp; /* LANE2 */ 74 * lecid, transaction id
70 unsigned int no_source_le_narp; /* LANE2 */ 75 */
71 } normal; 76 unsigned int targetless_le_arp; /* LANE2 */
72 struct atmlec_config_msg config; 77 unsigned int no_source_le_narp; /* LANE2 */
73 struct { 78 } normal;
74 uint16_t lec_id; /* requestor lec_id */ 79 struct atmlec_config_msg config;
75 uint32_t tran_id; /* transaction id */ 80 struct {
76 unsigned char mac_addr[ETH_ALEN]; /* dst mac addr */ 81 uint16_t lec_id; /* requestor lec_id */
77 unsigned char atm_addr[ATM_ESA_LEN]; /* reqestor ATM addr */ 82 uint32_t tran_id; /* transaction id */
78 } proxy; 83 unsigned char mac_addr[ETH_ALEN]; /* dst mac addr */
79 /* For mapping LE_ARP requests to responses. Filled by */ 84 unsigned char atm_addr[ATM_ESA_LEN]; /* reqestor ATM addr */
80 } content; /* zeppelin, returned by kernel. Used only when proxying */ 85 } proxy; /*
86 * For mapping LE_ARP requests to responses. Filled by
87 * zeppelin, returned by kernel. Used only when proxying
88 */
89 } content;
81} __ATM_API_ALIGN; 90} __ATM_API_ALIGN;
82 91
83struct atmlec_ioc { 92struct atmlec_ioc {
84 int dev_num; 93 int dev_num;
85 unsigned char atm_addr[ATM_ESA_LEN]; 94 unsigned char atm_addr[ATM_ESA_LEN];
86 unsigned char receive; /* 1= receive vcc, 0 = send vcc */ 95 unsigned char receive; /* 1= receive vcc, 0 = send vcc */
87}; 96};
88#endif /* _ATMLEC_H_ */ 97#endif /* _ATMLEC_H_ */
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 42719d07612a..c3aa09751814 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -95,12 +95,11 @@
95#define AUDIT_MAC_POLICY_LOAD 1403 /* Policy file load */ 95#define AUDIT_MAC_POLICY_LOAD 1403 /* Policy file load */
96#define AUDIT_MAC_STATUS 1404 /* Changed enforcing,permissive,off */ 96#define AUDIT_MAC_STATUS 1404 /* Changed enforcing,permissive,off */
97#define AUDIT_MAC_CONFIG_CHANGE 1405 /* Changes to booleans */ 97#define AUDIT_MAC_CONFIG_CHANGE 1405 /* Changes to booleans */
98#define AUDIT_MAC_UNLBL_ACCEPT 1406 /* NetLabel: allow unlabeled traffic */ 98#define AUDIT_MAC_UNLBL_ALLOW 1406 /* NetLabel: allow unlabeled traffic */
99#define AUDIT_MAC_UNLBL_DENY 1407 /* NetLabel: deny unlabeled traffic */ 99#define AUDIT_MAC_CIPSOV4_ADD 1407 /* NetLabel: add CIPSOv4 DOI entry */
100#define AUDIT_MAC_CIPSOV4_ADD 1408 /* NetLabel: add CIPSOv4 DOI entry */ 100#define AUDIT_MAC_CIPSOV4_DEL 1408 /* NetLabel: del CIPSOv4 DOI entry */
101#define AUDIT_MAC_CIPSOV4_DEL 1409 /* NetLabel: del CIPSOv4 DOI entry */ 101#define AUDIT_MAC_MAP_ADD 1409 /* NetLabel: add LSM domain mapping */
102#define AUDIT_MAC_MAP_ADD 1410 /* NetLabel: add LSM domain mapping */ 102#define AUDIT_MAC_MAP_DEL 1410 /* NetLabel: del LSM domain mapping */
103#define AUDIT_MAC_MAP_DEL 1411 /* NetLabel: del LSM domain mapping */
104 103
105#define AUDIT_FIRST_KERN_ANOM_MSG 1700 104#define AUDIT_FIRST_KERN_ANOM_MSG 1700
106#define AUDIT_LAST_KERN_ANOM_MSG 1799 105#define AUDIT_LAST_KERN_ANOM_MSG 1799
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index b7e85ff045ea..c9ffbc3843d5 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -507,6 +507,7 @@
507#define PCI_DEVICE_ID_AMD_8151_0 0x7454 507#define PCI_DEVICE_ID_AMD_8151_0 0x7454
508#define PCI_DEVICE_ID_AMD_8131_BRIDGE 0x7450 508#define PCI_DEVICE_ID_AMD_8131_BRIDGE 0x7450
509#define PCI_DEVICE_ID_AMD_8131_APIC 0x7451 509#define PCI_DEVICE_ID_AMD_8131_APIC 0x7451
510#define PCI_DEVICE_ID_AMD_8132_BRIDGE 0x7458
510#define PCI_DEVICE_ID_AMD_CS5536_ISA 0x2090 511#define PCI_DEVICE_ID_AMD_CS5536_ISA 0x2090
511#define PCI_DEVICE_ID_AMD_CS5536_FLASH 0x2091 512#define PCI_DEVICE_ID_AMD_CS5536_FLASH 0x2091
512#define PCI_DEVICE_ID_AMD_CS5536_AUDIO 0x2093 513#define PCI_DEVICE_ID_AMD_CS5536_AUDIO 0x2093
diff --git a/include/net/cipso_ipv4.h b/include/net/cipso_ipv4.h
index 5d6ae1b2b196..718b4d9c891f 100644
--- a/include/net/cipso_ipv4.h
+++ b/include/net/cipso_ipv4.h
@@ -129,7 +129,7 @@ extern int cipso_v4_rbm_strictvalid;
129#ifdef CONFIG_NETLABEL 129#ifdef CONFIG_NETLABEL
130int cipso_v4_doi_add(struct cipso_v4_doi *doi_def); 130int cipso_v4_doi_add(struct cipso_v4_doi *doi_def);
131int cipso_v4_doi_remove(u32 doi, 131int cipso_v4_doi_remove(u32 doi,
132 u32 audit_secid, 132 struct netlbl_audit *audit_info,
133 void (*callback) (struct rcu_head * head)); 133 void (*callback) (struct rcu_head * head));
134struct cipso_v4_doi *cipso_v4_doi_getdef(u32 doi); 134struct cipso_v4_doi *cipso_v4_doi_getdef(u32 doi);
135int cipso_v4_doi_walk(u32 *skip_cnt, 135int cipso_v4_doi_walk(u32 *skip_cnt,
@@ -145,7 +145,7 @@ static inline int cipso_v4_doi_add(struct cipso_v4_doi *doi_def)
145} 145}
146 146
147static inline int cipso_v4_doi_remove(u32 doi, 147static inline int cipso_v4_doi_remove(u32 doi,
148 u32 audit_secid, 148 struct netlbl_audit *audit_info,
149 void (*callback) (struct rcu_head * head)) 149 void (*callback) (struct rcu_head * head))
150{ 150{
151 return 0; 151 return 0;
diff --git a/include/net/netlabel.h b/include/net/netlabel.h
index 190bfdbbdba6..c63a58058e21 100644
--- a/include/net/netlabel.h
+++ b/include/net/netlabel.h
@@ -92,11 +92,17 @@
92 * 92 *
93 */ 93 */
94 94
95/* NetLabel audit information */
96struct netlbl_audit {
97 u32 secid;
98 uid_t loginuid;
99};
100
95/* Domain mapping definition struct */ 101/* Domain mapping definition struct */
96struct netlbl_dom_map; 102struct netlbl_dom_map;
97 103
98/* Domain mapping operations */ 104/* Domain mapping operations */
99int netlbl_domhsh_remove(const char *domain, u32 audit_secid); 105int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info);
100 106
101/* LSM security attributes */ 107/* LSM security attributes */
102struct netlbl_lsm_cache { 108struct netlbl_lsm_cache {
diff --git a/net/atm/lec.c b/net/atm/lec.c
index b4aa489849df..66c57c1091a8 100644
--- a/net/atm/lec.c
+++ b/net/atm/lec.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * lec.c: Lan Emulation driver 2 * lec.c: Lan Emulation driver
3 * Marko Kiiskila mkiiskila@yahoo.com
4 * 3 *
4 * Marko Kiiskila <mkiiskila@yahoo.com>
5 */ 5 */
6 6
7#include <linux/kernel.h> 7#include <linux/kernel.h>
@@ -38,7 +38,7 @@
38#include <linux/if_bridge.h> 38#include <linux/if_bridge.h>
39#include "../bridge/br_private.h" 39#include "../bridge/br_private.h"
40 40
41static unsigned char bridge_ula_lec[] = {0x01, 0x80, 0xc2, 0x00, 0x00}; 41static unsigned char bridge_ula_lec[] = { 0x01, 0x80, 0xc2, 0x00, 0x00 };
42#endif 42#endif
43 43
44/* Modular too */ 44/* Modular too */
@@ -55,38 +55,41 @@ static unsigned char bridge_ula_lec[] = {0x01, 0x80, 0xc2, 0x00, 0x00};
55#define DPRINTK(format,args...) 55#define DPRINTK(format,args...)
56#endif 56#endif
57 57
58#define DUMP_PACKETS 0 /* 0 = None, 58#define DUMP_PACKETS 0 /*
59 * 1 = 30 first bytes 59 * 0 = None,
60 * 2 = Whole packet 60 * 1 = 30 first bytes
61 */ 61 * 2 = Whole packet
62 */
62 63
63#define LEC_UNRES_QUE_LEN 8 /* number of tx packets to queue for a 64#define LEC_UNRES_QUE_LEN 8 /*
64 single destination while waiting for SVC */ 65 * number of tx packets to queue for a
66 * single destination while waiting for SVC
67 */
65 68
66static int lec_open(struct net_device *dev); 69static int lec_open(struct net_device *dev);
67static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev); 70static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev);
68static int lec_close(struct net_device *dev); 71static int lec_close(struct net_device *dev);
69static struct net_device_stats *lec_get_stats(struct net_device *dev); 72static struct net_device_stats *lec_get_stats(struct net_device *dev);
70static void lec_init(struct net_device *dev); 73static void lec_init(struct net_device *dev);
71static struct lec_arp_table* lec_arp_find(struct lec_priv *priv, 74static struct lec_arp_table *lec_arp_find(struct lec_priv *priv,
72 unsigned char *mac_addr); 75 unsigned char *mac_addr);
73static int lec_arp_remove(struct lec_priv *priv, 76static int lec_arp_remove(struct lec_priv *priv,
74 struct lec_arp_table *to_remove); 77 struct lec_arp_table *to_remove);
75/* LANE2 functions */ 78/* LANE2 functions */
76static void lane2_associate_ind (struct net_device *dev, u8 *mac_address, 79static void lane2_associate_ind(struct net_device *dev, u8 *mac_address,
77 u8 *tlvs, u32 sizeoftlvs); 80 u8 *tlvs, u32 sizeoftlvs);
78static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force, 81static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force,
79 u8 **tlvs, u32 *sizeoftlvs); 82 u8 **tlvs, u32 *sizeoftlvs);
80static int lane2_associate_req (struct net_device *dev, u8 *lan_dst, 83static int lane2_associate_req(struct net_device *dev, u8 *lan_dst,
81 u8 *tlvs, u32 sizeoftlvs); 84 u8 *tlvs, u32 sizeoftlvs);
82 85
83static int lec_addr_delete(struct lec_priv *priv, unsigned char *atm_addr, 86static int lec_addr_delete(struct lec_priv *priv, unsigned char *atm_addr,
84 unsigned long permanent); 87 unsigned long permanent);
85static void lec_arp_check_empties(struct lec_priv *priv, 88static void lec_arp_check_empties(struct lec_priv *priv,
86 struct atm_vcc *vcc, struct sk_buff *skb); 89 struct atm_vcc *vcc, struct sk_buff *skb);
87static void lec_arp_destroy(struct lec_priv *priv); 90static void lec_arp_destroy(struct lec_priv *priv);
88static void lec_arp_init(struct lec_priv *priv); 91static void lec_arp_init(struct lec_priv *priv);
89static struct atm_vcc* lec_arp_resolve(struct lec_priv *priv, 92static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
90 unsigned char *mac_to_find, 93 unsigned char *mac_to_find,
91 int is_rdesc, 94 int is_rdesc,
92 struct lec_arp_table **ret_entry); 95 struct lec_arp_table **ret_entry);
@@ -100,16 +103,30 @@ static void lec_set_flush_tran_id(struct lec_priv *priv,
100 unsigned long tran_id); 103 unsigned long tran_id);
101static void lec_vcc_added(struct lec_priv *priv, struct atmlec_ioc *ioc_data, 104static void lec_vcc_added(struct lec_priv *priv, struct atmlec_ioc *ioc_data,
102 struct atm_vcc *vcc, 105 struct atm_vcc *vcc,
103 void (*old_push)(struct atm_vcc *vcc, struct sk_buff *skb)); 106 void (*old_push) (struct atm_vcc *vcc,
107 struct sk_buff *skb));
104static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc); 108static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc);
105 109
110/* must be done under lec_arp_lock */
111static inline void lec_arp_hold(struct lec_arp_table *entry)
112{
113 atomic_inc(&entry->usage);
114}
115
116static inline void lec_arp_put(struct lec_arp_table *entry)
117{
118 if (atomic_dec_and_test(&entry->usage))
119 kfree(entry);
120}
121
122
106static struct lane2_ops lane2_ops = { 123static struct lane2_ops lane2_ops = {
107 lane2_resolve, /* resolve, spec 3.1.3 */ 124 lane2_resolve, /* resolve, spec 3.1.3 */
108 lane2_associate_req, /* associate_req, spec 3.1.4 */ 125 lane2_associate_req, /* associate_req, spec 3.1.4 */
109 NULL /* associate indicator, spec 3.1.5 */ 126 NULL /* associate indicator, spec 3.1.5 */
110}; 127};
111 128
112static unsigned char bus_mac[ETH_ALEN] = {0xff,0xff,0xff,0xff,0xff,0xff}; 129static unsigned char bus_mac[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
113 130
114/* Device structures */ 131/* Device structures */
115static struct net_device *dev_lec[MAX_LEC_ITF]; 132static struct net_device *dev_lec[MAX_LEC_ITF];
@@ -117,36 +134,39 @@ static struct net_device *dev_lec[MAX_LEC_ITF];
117#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) 134#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
118static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev) 135static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev)
119{ 136{
120 struct ethhdr *eth; 137 struct ethhdr *eth;
121 char *buff; 138 char *buff;
122 struct lec_priv *priv; 139 struct lec_priv *priv;
123 140
124 /* Check if this is a BPDU. If so, ask zeppelin to send 141 /*
125 * LE_TOPOLOGY_REQUEST with the same value of Topology Change bit 142 * Check if this is a BPDU. If so, ask zeppelin to send
126 * as the Config BPDU has */ 143 * LE_TOPOLOGY_REQUEST with the same value of Topology Change bit
127 eth = (struct ethhdr *)skb->data; 144 * as the Config BPDU has
128 buff = skb->data + skb->dev->hard_header_len; 145 */
129 if (*buff++ == 0x42 && *buff++ == 0x42 && *buff++ == 0x03) { 146 eth = (struct ethhdr *)skb->data;
147 buff = skb->data + skb->dev->hard_header_len;
148 if (*buff++ == 0x42 && *buff++ == 0x42 && *buff++ == 0x03) {
130 struct sock *sk; 149 struct sock *sk;
131 struct sk_buff *skb2; 150 struct sk_buff *skb2;
132 struct atmlec_msg *mesg; 151 struct atmlec_msg *mesg;
133 152
134 skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC); 153 skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC);
135 if (skb2 == NULL) return; 154 if (skb2 == NULL)
136 skb2->len = sizeof(struct atmlec_msg); 155 return;
137 mesg = (struct atmlec_msg *)skb2->data; 156 skb2->len = sizeof(struct atmlec_msg);
138 mesg->type = l_topology_change; 157 mesg = (struct atmlec_msg *)skb2->data;
139 buff += 4; 158 mesg->type = l_topology_change;
140 mesg->content.normal.flag = *buff & 0x01; /* 0x01 is topology change */ 159 buff += 4;
141 160 mesg->content.normal.flag = *buff & 0x01; /* 0x01 is topology change */
142 priv = (struct lec_priv *)dev->priv; 161
143 atm_force_charge(priv->lecd, skb2->truesize); 162 priv = (struct lec_priv *)dev->priv;
163 atm_force_charge(priv->lecd, skb2->truesize);
144 sk = sk_atm(priv->lecd); 164 sk = sk_atm(priv->lecd);
145 skb_queue_tail(&sk->sk_receive_queue, skb2); 165 skb_queue_tail(&sk->sk_receive_queue, skb2);
146 sk->sk_data_ready(sk, skb2->len); 166 sk->sk_data_ready(sk, skb2->len);
147 } 167 }
148 168
149 return; 169 return;
150} 170}
151#endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ 171#endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */
152 172
@@ -162,36 +182,35 @@ static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev)
162#ifdef CONFIG_TR 182#ifdef CONFIG_TR
163static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc) 183static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc)
164{ 184{
165 struct trh_hdr *trh; 185 struct trh_hdr *trh;
166 int riflen, num_rdsc; 186 int riflen, num_rdsc;
167 187
168 trh = (struct trh_hdr *)packet; 188 trh = (struct trh_hdr *)packet;
169 if (trh->daddr[0] & (uint8_t)0x80) 189 if (trh->daddr[0] & (uint8_t) 0x80)
170 return bus_mac; /* multicast */ 190 return bus_mac; /* multicast */
171 191
172 if (trh->saddr[0] & TR_RII) { 192 if (trh->saddr[0] & TR_RII) {
173 riflen = (ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8; 193 riflen = (ntohs(trh->rcf) & TR_RCF_LEN_MASK) >> 8;
174 if ((ntohs(trh->rcf) >> 13) != 0) 194 if ((ntohs(trh->rcf) >> 13) != 0)
175 return bus_mac; /* ARE or STE */ 195 return bus_mac; /* ARE or STE */
176 } 196 } else
177 else 197 return trh->daddr; /* not source routed */
178 return trh->daddr; /* not source routed */ 198
179 199 if (riflen < 6)
180 if (riflen < 6) 200 return trh->daddr; /* last hop, source routed */
181 return trh->daddr; /* last hop, source routed */ 201
182 202 /* riflen is 6 or more, packet has more than one route descriptor */
183 /* riflen is 6 or more, packet has more than one route descriptor */ 203 num_rdsc = (riflen / 2) - 1;
184 num_rdsc = (riflen/2) - 1; 204 memset(rdesc, 0, ETH_ALEN);
185 memset(rdesc, 0, ETH_ALEN); 205 /* offset 4 comes from LAN destination field in LE control frames */
186 /* offset 4 comes from LAN destination field in LE control frames */ 206 if (trh->rcf & htons((uint16_t) TR_RCF_DIR_BIT))
187 if (trh->rcf & htons((uint16_t)TR_RCF_DIR_BIT)) 207 memcpy(&rdesc[4], &trh->rseg[num_rdsc - 2], sizeof(uint16_t));
188 memcpy(&rdesc[4], &trh->rseg[num_rdsc-2], sizeof(uint16_t)); 208 else {
189 else { 209 memcpy(&rdesc[4], &trh->rseg[1], sizeof(uint16_t));
190 memcpy(&rdesc[4], &trh->rseg[1], sizeof(uint16_t)); 210 rdesc[5] = ((ntohs(trh->rseg[0]) & 0x000f) | (rdesc[5] & 0xf0));
191 rdesc[5] = ((ntohs(trh->rseg[0]) & 0x000f) | (rdesc[5] & 0xf0)); 211 }
192 } 212
193 213 return NULL;
194 return NULL;
195} 214}
196#endif /* CONFIG_TR */ 215#endif /* CONFIG_TR */
197 216
@@ -204,15 +223,14 @@ static unsigned char *get_tr_dst(unsigned char *packet, unsigned char *rdesc)
204 * there is non-reboot way to recover if something goes wrong. 223 * there is non-reboot way to recover if something goes wrong.
205 */ 224 */
206 225
207static int 226static int lec_open(struct net_device *dev)
208lec_open(struct net_device *dev)
209{ 227{
210 struct lec_priv *priv = (struct lec_priv *)dev->priv; 228 struct lec_priv *priv = (struct lec_priv *)dev->priv;
211 229
212 netif_start_queue(dev); 230 netif_start_queue(dev);
213 memset(&priv->stats,0,sizeof(struct net_device_stats)); 231 memset(&priv->stats, 0, sizeof(struct net_device_stats));
214 232
215 return 0; 233 return 0;
216} 234}
217 235
218static __inline__ void 236static __inline__ void
@@ -231,160 +249,166 @@ lec_send(struct atm_vcc *vcc, struct sk_buff *skb, struct lec_priv *priv)
231 priv->stats.tx_bytes += skb->len; 249 priv->stats.tx_bytes += skb->len;
232} 250}
233 251
234static void 252static void lec_tx_timeout(struct net_device *dev)
235lec_tx_timeout(struct net_device *dev)
236{ 253{
237 printk(KERN_INFO "%s: tx timeout\n", dev->name); 254 printk(KERN_INFO "%s: tx timeout\n", dev->name);
238 dev->trans_start = jiffies; 255 dev->trans_start = jiffies;
239 netif_wake_queue(dev); 256 netif_wake_queue(dev);
240} 257}
241 258
242static int 259static int lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
243lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
244{ 260{
245 struct sk_buff *skb2; 261 struct sk_buff *skb2;
246 struct lec_priv *priv = (struct lec_priv *)dev->priv; 262 struct lec_priv *priv = (struct lec_priv *)dev->priv;
247 struct lecdatahdr_8023 *lec_h; 263 struct lecdatahdr_8023 *lec_h;
248 struct atm_vcc *vcc; 264 struct atm_vcc *vcc;
249 struct lec_arp_table *entry; 265 struct lec_arp_table *entry;
250 unsigned char *dst; 266 unsigned char *dst;
251 int min_frame_size; 267 int min_frame_size;
252#ifdef CONFIG_TR 268#ifdef CONFIG_TR
253 unsigned char rdesc[ETH_ALEN]; /* Token Ring route descriptor */ 269 unsigned char rdesc[ETH_ALEN]; /* Token Ring route descriptor */
254#endif 270#endif
255 int is_rdesc; 271 int is_rdesc;
256#if DUMP_PACKETS > 0 272#if DUMP_PACKETS > 0
257 char buf[300]; 273 char buf[300];
258 int i=0; 274 int i = 0;
259#endif /* DUMP_PACKETS >0 */ 275#endif /* DUMP_PACKETS >0 */
260 276
261 DPRINTK("lec_start_xmit called\n"); 277 DPRINTK("lec_start_xmit called\n");
262 if (!priv->lecd) { 278 if (!priv->lecd) {
263 printk("%s:No lecd attached\n",dev->name); 279 printk("%s:No lecd attached\n", dev->name);
264 priv->stats.tx_errors++; 280 priv->stats.tx_errors++;
265 netif_stop_queue(dev); 281 netif_stop_queue(dev);
266 return -EUNATCH; 282 return -EUNATCH;
267 } 283 }
268 284
269 DPRINTK("skbuff head:%lx data:%lx tail:%lx end:%lx\n", 285 DPRINTK("skbuff head:%lx data:%lx tail:%lx end:%lx\n",
270 (long)skb->head, (long)skb->data, (long)skb->tail, 286 (long)skb->head, (long)skb->data, (long)skb->tail,
271 (long)skb->end); 287 (long)skb->end);
272#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) 288#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
273 if (memcmp(skb->data, bridge_ula_lec, sizeof(bridge_ula_lec)) == 0) 289 if (memcmp(skb->data, bridge_ula_lec, sizeof(bridge_ula_lec)) == 0)
274 lec_handle_bridge(skb, dev); 290 lec_handle_bridge(skb, dev);
275#endif 291#endif
276 292
277 /* Make sure we have room for lec_id */ 293 /* Make sure we have room for lec_id */
278 if (skb_headroom(skb) < 2) { 294 if (skb_headroom(skb) < 2) {
279 295
280 DPRINTK("lec_start_xmit: reallocating skb\n"); 296 DPRINTK("lec_start_xmit: reallocating skb\n");
281 skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN); 297 skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN);
282 kfree_skb(skb); 298 kfree_skb(skb);
283 if (skb2 == NULL) return 0; 299 if (skb2 == NULL)
284 skb = skb2; 300 return 0;
285 } 301 skb = skb2;
286 skb_push(skb, 2); 302 }
303 skb_push(skb, 2);
287 304
288 /* Put le header to place, works for TokenRing too */ 305 /* Put le header to place, works for TokenRing too */
289 lec_h = (struct lecdatahdr_8023*)skb->data; 306 lec_h = (struct lecdatahdr_8023 *)skb->data;
290 lec_h->le_header = htons(priv->lecid); 307 lec_h->le_header = htons(priv->lecid);
291 308
292#ifdef CONFIG_TR 309#ifdef CONFIG_TR
293 /* Ugly. Use this to realign Token Ring packets for 310 /*
294 * e.g. PCA-200E driver. */ 311 * Ugly. Use this to realign Token Ring packets for
295 if (priv->is_trdev) { 312 * e.g. PCA-200E driver.
296 skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN); 313 */
297 kfree_skb(skb); 314 if (priv->is_trdev) {
298 if (skb2 == NULL) return 0; 315 skb2 = skb_realloc_headroom(skb, LEC_HEADER_LEN);
299 skb = skb2; 316 kfree_skb(skb);
300 } 317 if (skb2 == NULL)
318 return 0;
319 skb = skb2;
320 }
301#endif 321#endif
302 322
303#if DUMP_PACKETS > 0 323#if DUMP_PACKETS > 0
304 printk("%s: send datalen:%ld lecid:%4.4x\n", dev->name, 324 printk("%s: send datalen:%ld lecid:%4.4x\n", dev->name,
305 skb->len, priv->lecid); 325 skb->len, priv->lecid);
306#if DUMP_PACKETS >= 2 326#if DUMP_PACKETS >= 2
307 for(i=0;i<skb->len && i <99;i++) { 327 for (i = 0; i < skb->len && i < 99; i++) {
308 sprintf(buf+i*3,"%2.2x ",0xff&skb->data[i]); 328 sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]);
309 } 329 }
310#elif DUMP_PACKETS >= 1 330#elif DUMP_PACKETS >= 1
311 for(i=0;i<skb->len && i < 30;i++) { 331 for (i = 0; i < skb->len && i < 30; i++) {
312 sprintf(buf+i*3,"%2.2x ", 0xff&skb->data[i]); 332 sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]);
313 } 333 }
314#endif /* DUMP_PACKETS >= 1 */ 334#endif /* DUMP_PACKETS >= 1 */
315 if (i==skb->len) 335 if (i == skb->len)
316 printk("%s\n",buf); 336 printk("%s\n", buf);
317 else 337 else
318 printk("%s...\n",buf); 338 printk("%s...\n", buf);
319#endif /* DUMP_PACKETS > 0 */ 339#endif /* DUMP_PACKETS > 0 */
320 340
321 /* Minimum ethernet-frame size */ 341 /* Minimum ethernet-frame size */
322#ifdef CONFIG_TR 342#ifdef CONFIG_TR
323 if (priv->is_trdev) 343 if (priv->is_trdev)
324 min_frame_size = LEC_MINIMUM_8025_SIZE; 344 min_frame_size = LEC_MINIMUM_8025_SIZE;
325 else 345 else
326#endif 346#endif
327 min_frame_size = LEC_MINIMUM_8023_SIZE; 347 min_frame_size = LEC_MINIMUM_8023_SIZE;
328 if (skb->len < min_frame_size) { 348 if (skb->len < min_frame_size) {
329 if ((skb->len + skb_tailroom(skb)) < min_frame_size) { 349 if ((skb->len + skb_tailroom(skb)) < min_frame_size) {
330 skb2 = skb_copy_expand(skb, 0, 350 skb2 = skb_copy_expand(skb, 0,
331 min_frame_size - skb->truesize, GFP_ATOMIC); 351 min_frame_size - skb->truesize,
332 dev_kfree_skb(skb); 352 GFP_ATOMIC);
333 if (skb2 == NULL) { 353 dev_kfree_skb(skb);
334 priv->stats.tx_dropped++; 354 if (skb2 == NULL) {
335 return 0; 355 priv->stats.tx_dropped++;
336 } 356 return 0;
337 skb = skb2; 357 }
338 } 358 skb = skb2;
359 }
339 skb_put(skb, min_frame_size - skb->len); 360 skb_put(skb, min_frame_size - skb->len);
340 } 361 }
341 362
342 /* Send to right vcc */ 363 /* Send to right vcc */
343 is_rdesc = 0; 364 is_rdesc = 0;
344 dst = lec_h->h_dest; 365 dst = lec_h->h_dest;
345#ifdef CONFIG_TR 366#ifdef CONFIG_TR
346 if (priv->is_trdev) { 367 if (priv->is_trdev) {
347 dst = get_tr_dst(skb->data+2, rdesc); 368 dst = get_tr_dst(skb->data + 2, rdesc);
348 if (dst == NULL) { 369 if (dst == NULL) {
349 dst = rdesc; 370 dst = rdesc;
350 is_rdesc = 1; 371 is_rdesc = 1;
351 } 372 }
352 } 373 }
353#endif 374#endif
354 entry = NULL; 375 entry = NULL;
355 vcc = lec_arp_resolve(priv, dst, is_rdesc, &entry); 376 vcc = lec_arp_resolve(priv, dst, is_rdesc, &entry);
356 DPRINTK("%s:vcc:%p vcc_flags:%x, entry:%p\n", dev->name, 377 DPRINTK("%s:vcc:%p vcc_flags:%x, entry:%p\n", dev->name,
357 vcc, vcc?vcc->flags:0, entry); 378 vcc, vcc ? vcc->flags : 0, entry);
358 if (!vcc || !test_bit(ATM_VF_READY,&vcc->flags)) { 379 if (!vcc || !test_bit(ATM_VF_READY, &vcc->flags)) {
359 if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) { 380 if (entry && (entry->tx_wait.qlen < LEC_UNRES_QUE_LEN)) {
360 DPRINTK("%s:lec_start_xmit: queuing packet, ", dev->name); 381 DPRINTK("%s:lec_start_xmit: queuing packet, ",
361 DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n", 382 dev->name);
362 lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2], 383 DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n",
363 lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]); 384 lec_h->h_dest[0], lec_h->h_dest[1],
364 skb_queue_tail(&entry->tx_wait, skb); 385 lec_h->h_dest[2], lec_h->h_dest[3],
365 } else { 386 lec_h->h_dest[4], lec_h->h_dest[5]);
366 DPRINTK("%s:lec_start_xmit: tx queue full or no arp entry, dropping, ", dev->name); 387 skb_queue_tail(&entry->tx_wait, skb);
367 DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n", 388 } else {
368 lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2], 389 DPRINTK
369 lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]); 390 ("%s:lec_start_xmit: tx queue full or no arp entry, dropping, ",
370 priv->stats.tx_dropped++; 391 dev->name);
371 dev_kfree_skb(skb); 392 DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n",
372 } 393 lec_h->h_dest[0], lec_h->h_dest[1],
373 return 0; 394 lec_h->h_dest[2], lec_h->h_dest[3],
374 } 395 lec_h->h_dest[4], lec_h->h_dest[5]);
375 396 priv->stats.tx_dropped++;
376#if DUMP_PACKETS > 0 397 dev_kfree_skb(skb);
377 printk("%s:sending to vpi:%d vci:%d\n", dev->name, 398 }
378 vcc->vpi, vcc->vci); 399 goto out;
400 }
401#if DUMP_PACKETS > 0
402 printk("%s:sending to vpi:%d vci:%d\n", dev->name, vcc->vpi, vcc->vci);
379#endif /* DUMP_PACKETS > 0 */ 403#endif /* DUMP_PACKETS > 0 */
380 404
381 while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) { 405 while (entry && (skb2 = skb_dequeue(&entry->tx_wait))) {
382 DPRINTK("lec.c: emptying tx queue, "); 406 DPRINTK("lec.c: emptying tx queue, ");
383 DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n", 407 DPRINTK("MAC address 0x%02x:%02x:%02x:%02x:%02x:%02x\n",
384 lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2], 408 lec_h->h_dest[0], lec_h->h_dest[1], lec_h->h_dest[2],
385 lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]); 409 lec_h->h_dest[3], lec_h->h_dest[4], lec_h->h_dest[5]);
386 lec_send(vcc, skb2, priv); 410 lec_send(vcc, skb2, priv);
387 } 411 }
388 412
389 lec_send(vcc, skb, priv); 413 lec_send(vcc, skb, priv);
390 414
@@ -404,210 +428,219 @@ lec_start_xmit(struct sk_buff *skb, struct net_device *dev)
404 netif_wake_queue(dev); 428 netif_wake_queue(dev);
405 } 429 }
406 430
431out:
432 if (entry)
433 lec_arp_put(entry);
407 dev->trans_start = jiffies; 434 dev->trans_start = jiffies;
408 return 0; 435 return 0;
409} 436}
410 437
411/* The inverse routine to net_open(). */ 438/* The inverse routine to net_open(). */
412static int 439static int lec_close(struct net_device *dev)
413lec_close(struct net_device *dev)
414{ 440{
415 netif_stop_queue(dev); 441 netif_stop_queue(dev);
416 return 0; 442 return 0;
417} 443}
418 444
419/* 445/*
420 * Get the current statistics. 446 * Get the current statistics.
421 * This may be called with the card open or closed. 447 * This may be called with the card open or closed.
422 */ 448 */
423static struct net_device_stats * 449static struct net_device_stats *lec_get_stats(struct net_device *dev)
424lec_get_stats(struct net_device *dev)
425{ 450{
426 return &((struct lec_priv *)dev->priv)->stats; 451 return &((struct lec_priv *)dev->priv)->stats;
427} 452}
428 453
429static int 454static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
430lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb)
431{ 455{
432 unsigned long flags; 456 unsigned long flags;
433 struct net_device *dev = (struct net_device*)vcc->proto_data; 457 struct net_device *dev = (struct net_device *)vcc->proto_data;
434 struct lec_priv *priv = (struct lec_priv*)dev->priv; 458 struct lec_priv *priv = (struct lec_priv *)dev->priv;
435 struct atmlec_msg *mesg; 459 struct atmlec_msg *mesg;
436 struct lec_arp_table *entry; 460 struct lec_arp_table *entry;
437 int i; 461 int i;
438 char *tmp; /* FIXME */ 462 char *tmp; /* FIXME */
439 463
440 atomic_sub(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); 464 atomic_sub(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
441 mesg = (struct atmlec_msg *)skb->data; 465 mesg = (struct atmlec_msg *)skb->data;
442 tmp = skb->data; 466 tmp = skb->data;
443 tmp += sizeof(struct atmlec_msg); 467 tmp += sizeof(struct atmlec_msg);
444 DPRINTK("%s: msg from zeppelin:%d\n", dev->name, mesg->type); 468 DPRINTK("%s: msg from zeppelin:%d\n", dev->name, mesg->type);
445 switch(mesg->type) { 469 switch (mesg->type) {
446 case l_set_mac_addr: 470 case l_set_mac_addr:
447 for (i=0;i<6;i++) { 471 for (i = 0; i < 6; i++) {
448 dev->dev_addr[i] = mesg->content.normal.mac_addr[i]; 472 dev->dev_addr[i] = mesg->content.normal.mac_addr[i];
449 } 473 }
450 break; 474 break;
451 case l_del_mac_addr: 475 case l_del_mac_addr:
452 for(i=0;i<6;i++) { 476 for (i = 0; i < 6; i++) {
453 dev->dev_addr[i] = 0; 477 dev->dev_addr[i] = 0;
454 } 478 }
455 break; 479 break;
456 case l_addr_delete: 480 case l_addr_delete:
457 lec_addr_delete(priv, mesg->content.normal.atm_addr, 481 lec_addr_delete(priv, mesg->content.normal.atm_addr,
458 mesg->content.normal.flag); 482 mesg->content.normal.flag);
459 break; 483 break;
460 case l_topology_change: 484 case l_topology_change:
461 priv->topology_change = mesg->content.normal.flag; 485 priv->topology_change = mesg->content.normal.flag;
462 break; 486 break;
463 case l_flush_complete: 487 case l_flush_complete:
464 lec_flush_complete(priv, mesg->content.normal.flag); 488 lec_flush_complete(priv, mesg->content.normal.flag);
465 break; 489 break;
466 case l_narp_req: /* LANE2: see 7.1.35 in the lane2 spec */ 490 case l_narp_req: /* LANE2: see 7.1.35 in the lane2 spec */
467 spin_lock_irqsave(&priv->lec_arp_lock, flags); 491 spin_lock_irqsave(&priv->lec_arp_lock, flags);
468 entry = lec_arp_find(priv, mesg->content.normal.mac_addr); 492 entry = lec_arp_find(priv, mesg->content.normal.mac_addr);
469 lec_arp_remove(priv, entry); 493 lec_arp_remove(priv, entry);
470 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); 494 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
471 495
472 if (mesg->content.normal.no_source_le_narp) 496 if (mesg->content.normal.no_source_le_narp)
473 break; 497 break;
474 /* FALL THROUGH */ 498 /* FALL THROUGH */
475 case l_arp_update: 499 case l_arp_update:
476 lec_arp_update(priv, mesg->content.normal.mac_addr, 500 lec_arp_update(priv, mesg->content.normal.mac_addr,
477 mesg->content.normal.atm_addr, 501 mesg->content.normal.atm_addr,
478 mesg->content.normal.flag, 502 mesg->content.normal.flag,
479 mesg->content.normal.targetless_le_arp); 503 mesg->content.normal.targetless_le_arp);
480 DPRINTK("lec: in l_arp_update\n"); 504 DPRINTK("lec: in l_arp_update\n");
481 if (mesg->sizeoftlvs != 0) { /* LANE2 3.1.5 */ 505 if (mesg->sizeoftlvs != 0) { /* LANE2 3.1.5 */
482 DPRINTK("lec: LANE2 3.1.5, got tlvs, size %d\n", mesg->sizeoftlvs); 506 DPRINTK("lec: LANE2 3.1.5, got tlvs, size %d\n",
483 lane2_associate_ind(dev, 507 mesg->sizeoftlvs);
484 mesg->content.normal.mac_addr, 508 lane2_associate_ind(dev, mesg->content.normal.mac_addr,
485 tmp, mesg->sizeoftlvs); 509 tmp, mesg->sizeoftlvs);
486 } 510 }
487 break; 511 break;
488 case l_config: 512 case l_config:
489 priv->maximum_unknown_frame_count = 513 priv->maximum_unknown_frame_count =
490 mesg->content.config.maximum_unknown_frame_count; 514 mesg->content.config.maximum_unknown_frame_count;
491 priv->max_unknown_frame_time = 515 priv->max_unknown_frame_time =
492 (mesg->content.config.max_unknown_frame_time*HZ); 516 (mesg->content.config.max_unknown_frame_time * HZ);
493 priv->max_retry_count = 517 priv->max_retry_count = mesg->content.config.max_retry_count;
494 mesg->content.config.max_retry_count; 518 priv->aging_time = (mesg->content.config.aging_time * HZ);
495 priv->aging_time = (mesg->content.config.aging_time*HZ); 519 priv->forward_delay_time =
496 priv->forward_delay_time = 520 (mesg->content.config.forward_delay_time * HZ);
497 (mesg->content.config.forward_delay_time*HZ); 521 priv->arp_response_time =
498 priv->arp_response_time = 522 (mesg->content.config.arp_response_time * HZ);
499 (mesg->content.config.arp_response_time*HZ); 523 priv->flush_timeout = (mesg->content.config.flush_timeout * HZ);
500 priv->flush_timeout = (mesg->content.config.flush_timeout*HZ); 524 priv->path_switching_delay =
501 priv->path_switching_delay = 525 (mesg->content.config.path_switching_delay * HZ);
502 (mesg->content.config.path_switching_delay*HZ); 526 priv->lane_version = mesg->content.config.lane_version; /* LANE2 */
503 priv->lane_version = mesg->content.config.lane_version; /* LANE2 */
504 priv->lane2_ops = NULL; 527 priv->lane2_ops = NULL;
505 if (priv->lane_version > 1) 528 if (priv->lane_version > 1)
506 priv->lane2_ops = &lane2_ops; 529 priv->lane2_ops = &lane2_ops;
507 if (dev->change_mtu(dev, mesg->content.config.mtu)) 530 if (dev->change_mtu(dev, mesg->content.config.mtu))
508 printk("%s: change_mtu to %d failed\n", dev->name, 531 printk("%s: change_mtu to %d failed\n", dev->name,
509 mesg->content.config.mtu); 532 mesg->content.config.mtu);
510 priv->is_proxy = mesg->content.config.is_proxy; 533 priv->is_proxy = mesg->content.config.is_proxy;
511 break; 534 break;
512 case l_flush_tran_id: 535 case l_flush_tran_id:
513 lec_set_flush_tran_id(priv, mesg->content.normal.atm_addr, 536 lec_set_flush_tran_id(priv, mesg->content.normal.atm_addr,
514 mesg->content.normal.flag); 537 mesg->content.normal.flag);
515 break; 538 break;
516 case l_set_lecid: 539 case l_set_lecid:
517 priv->lecid=(unsigned short)(0xffff&mesg->content.normal.flag); 540 priv->lecid =
518 break; 541 (unsigned short)(0xffff & mesg->content.normal.flag);
519 case l_should_bridge: { 542 break;
543 case l_should_bridge:
520#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) 544#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
521 struct net_bridge_fdb_entry *f; 545 {
522 546 struct net_bridge_fdb_entry *f;
523 DPRINTK("%s: bridge zeppelin asks about 0x%02x:%02x:%02x:%02x:%02x:%02x\n", 547
524 dev->name, 548 DPRINTK
525 mesg->content.proxy.mac_addr[0], mesg->content.proxy.mac_addr[1], 549 ("%s: bridge zeppelin asks about 0x%02x:%02x:%02x:%02x:%02x:%02x\n",
526 mesg->content.proxy.mac_addr[2], mesg->content.proxy.mac_addr[3], 550 dev->name, mesg->content.proxy.mac_addr[0],
527 mesg->content.proxy.mac_addr[4], mesg->content.proxy.mac_addr[5]); 551 mesg->content.proxy.mac_addr[1],
528 552 mesg->content.proxy.mac_addr[2],
529 if (br_fdb_get_hook == NULL || dev->br_port == NULL) 553 mesg->content.proxy.mac_addr[3],
530 break; 554 mesg->content.proxy.mac_addr[4],
531 555 mesg->content.proxy.mac_addr[5]);
532 f = br_fdb_get_hook(dev->br_port->br, mesg->content.proxy.mac_addr); 556
533 if (f != NULL && 557 if (br_fdb_get_hook == NULL || dev->br_port == NULL)
534 f->dst->dev != dev && 558 break;
535 f->dst->state == BR_STATE_FORWARDING) { 559
536 /* hit from bridge table, send LE_ARP_RESPONSE */ 560 f = br_fdb_get_hook(dev->br_port->br,
537 struct sk_buff *skb2; 561 mesg->content.proxy.mac_addr);
538 struct sock *sk; 562 if (f != NULL && f->dst->dev != dev
539 563 && f->dst->state == BR_STATE_FORWARDING) {
540 DPRINTK("%s: entry found, responding to zeppelin\n", dev->name); 564 /* hit from bridge table, send LE_ARP_RESPONSE */
541 skb2 = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC); 565 struct sk_buff *skb2;
542 if (skb2 == NULL) { 566 struct sock *sk;
543 br_fdb_put_hook(f); 567
544 break; 568 DPRINTK
545 } 569 ("%s: entry found, responding to zeppelin\n",
546 skb2->len = sizeof(struct atmlec_msg); 570 dev->name);
547 memcpy(skb2->data, mesg, sizeof(struct atmlec_msg)); 571 skb2 =
548 atm_force_charge(priv->lecd, skb2->truesize); 572 alloc_skb(sizeof(struct atmlec_msg),
549 sk = sk_atm(priv->lecd); 573 GFP_ATOMIC);
550 skb_queue_tail(&sk->sk_receive_queue, skb2); 574 if (skb2 == NULL) {
551 sk->sk_data_ready(sk, skb2->len); 575 br_fdb_put_hook(f);
552 } 576 break;
553 if (f != NULL) br_fdb_put_hook(f); 577 }
578 skb2->len = sizeof(struct atmlec_msg);
579 memcpy(skb2->data, mesg,
580 sizeof(struct atmlec_msg));
581 atm_force_charge(priv->lecd, skb2->truesize);
582 sk = sk_atm(priv->lecd);
583 skb_queue_tail(&sk->sk_receive_queue, skb2);
584 sk->sk_data_ready(sk, skb2->len);
585 }
586 if (f != NULL)
587 br_fdb_put_hook(f);
588 }
554#endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */ 589#endif /* defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) */
555 } 590 break;
556 break; 591 default:
557 default: 592 printk("%s: Unknown message type %d\n", dev->name, mesg->type);
558 printk("%s: Unknown message type %d\n", dev->name, mesg->type); 593 dev_kfree_skb(skb);
559 dev_kfree_skb(skb); 594 return -EINVAL;
560 return -EINVAL; 595 }
561 } 596 dev_kfree_skb(skb);
562 dev_kfree_skb(skb); 597 return 0;
563 return 0;
564} 598}
565 599
566static void 600static void lec_atm_close(struct atm_vcc *vcc)
567lec_atm_close(struct atm_vcc *vcc)
568{ 601{
569 struct sk_buff *skb; 602 struct sk_buff *skb;
570 struct net_device *dev = (struct net_device *)vcc->proto_data; 603 struct net_device *dev = (struct net_device *)vcc->proto_data;
571 struct lec_priv *priv = (struct lec_priv *)dev->priv; 604 struct lec_priv *priv = (struct lec_priv *)dev->priv;
572 605
573 priv->lecd = NULL; 606 priv->lecd = NULL;
574 /* Do something needful? */ 607 /* Do something needful? */
575 608
576 netif_stop_queue(dev); 609 netif_stop_queue(dev);
577 lec_arp_destroy(priv); 610 lec_arp_destroy(priv);
578 611
579 if (skb_peek(&sk_atm(vcc)->sk_receive_queue)) 612 if (skb_peek(&sk_atm(vcc)->sk_receive_queue))
580 printk("%s lec_atm_close: closing with messages pending\n", 613 printk("%s lec_atm_close: closing with messages pending\n",
581 dev->name); 614 dev->name);
582 while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue)) != NULL) { 615 while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue)) != NULL) {
583 atm_return(vcc, skb->truesize); 616 atm_return(vcc, skb->truesize);
584 dev_kfree_skb(skb); 617 dev_kfree_skb(skb);
585 } 618 }
586 619
587 printk("%s: Shut down!\n", dev->name); 620 printk("%s: Shut down!\n", dev->name);
588 module_put(THIS_MODULE); 621 module_put(THIS_MODULE);
589} 622}
590 623
591static struct atmdev_ops lecdev_ops = { 624static struct atmdev_ops lecdev_ops = {
592 .close = lec_atm_close, 625 .close = lec_atm_close,
593 .send = lec_atm_send 626 .send = lec_atm_send
594}; 627};
595 628
596static struct atm_dev lecatm_dev = { 629static struct atm_dev lecatm_dev = {
597 .ops = &lecdev_ops, 630 .ops = &lecdev_ops,
598 .type = "lec", 631 .type = "lec",
599 .number = 999, /* dummy device number */ 632 .number = 999, /* dummy device number */
600 .lock = SPIN_LOCK_UNLOCKED 633 .lock = SPIN_LOCK_UNLOCKED
601}; 634};
602 635
603/* 636/*
604 * LANE2: new argument struct sk_buff *data contains 637 * LANE2: new argument struct sk_buff *data contains
605 * the LE_ARP based TLVs introduced in the LANE2 spec 638 * the LE_ARP based TLVs introduced in the LANE2 spec
606 */ 639 */
607static int 640static int
608send_to_lecd(struct lec_priv *priv, atmlec_msg_type type, 641send_to_lecd(struct lec_priv *priv, atmlec_msg_type type,
609 unsigned char *mac_addr, unsigned char *atm_addr, 642 unsigned char *mac_addr, unsigned char *atm_addr,
610 struct sk_buff *data) 643 struct sk_buff *data)
611{ 644{
612 struct sock *sk; 645 struct sock *sk;
613 struct sk_buff *skb; 646 struct sk_buff *skb;
@@ -621,187 +654,193 @@ send_to_lecd(struct lec_priv *priv, atmlec_msg_type type,
621 return -1; 654 return -1;
622 skb->len = sizeof(struct atmlec_msg); 655 skb->len = sizeof(struct atmlec_msg);
623 mesg = (struct atmlec_msg *)skb->data; 656 mesg = (struct atmlec_msg *)skb->data;
624 memset(mesg, 0, sizeof(struct atmlec_msg)); 657 memset(mesg, 0, sizeof(struct atmlec_msg));
625 mesg->type = type; 658 mesg->type = type;
626 if (data != NULL) 659 if (data != NULL)
627 mesg->sizeoftlvs = data->len; 660 mesg->sizeoftlvs = data->len;
628 if (mac_addr) 661 if (mac_addr)
629 memcpy(&mesg->content.normal.mac_addr, mac_addr, ETH_ALEN); 662 memcpy(&mesg->content.normal.mac_addr, mac_addr, ETH_ALEN);
630 else 663 else
631 mesg->content.normal.targetless_le_arp = 1; 664 mesg->content.normal.targetless_le_arp = 1;
632 if (atm_addr) 665 if (atm_addr)
633 memcpy(&mesg->content.normal.atm_addr, atm_addr, ATM_ESA_LEN); 666 memcpy(&mesg->content.normal.atm_addr, atm_addr, ATM_ESA_LEN);
634 667
635 atm_force_charge(priv->lecd, skb->truesize); 668 atm_force_charge(priv->lecd, skb->truesize);
636 sk = sk_atm(priv->lecd); 669 sk = sk_atm(priv->lecd);
637 skb_queue_tail(&sk->sk_receive_queue, skb); 670 skb_queue_tail(&sk->sk_receive_queue, skb);
638 sk->sk_data_ready(sk, skb->len); 671 sk->sk_data_ready(sk, skb->len);
639 672
640 if (data != NULL) { 673 if (data != NULL) {
641 DPRINTK("lec: about to send %d bytes of data\n", data->len); 674 DPRINTK("lec: about to send %d bytes of data\n", data->len);
642 atm_force_charge(priv->lecd, data->truesize); 675 atm_force_charge(priv->lecd, data->truesize);
643 skb_queue_tail(&sk->sk_receive_queue, data); 676 skb_queue_tail(&sk->sk_receive_queue, data);
644 sk->sk_data_ready(sk, skb->len); 677 sk->sk_data_ready(sk, skb->len);
645 } 678 }
646 679
647 return 0; 680 return 0;
648} 681}
649 682
650/* shamelessly stolen from drivers/net/net_init.c */ 683/* shamelessly stolen from drivers/net/net_init.c */
651static int lec_change_mtu(struct net_device *dev, int new_mtu) 684static int lec_change_mtu(struct net_device *dev, int new_mtu)
652{ 685{
653 if ((new_mtu < 68) || (new_mtu > 18190)) 686 if ((new_mtu < 68) || (new_mtu > 18190))
654 return -EINVAL; 687 return -EINVAL;
655 dev->mtu = new_mtu; 688 dev->mtu = new_mtu;
656 return 0; 689 return 0;
657} 690}
658 691
659static void lec_set_multicast_list(struct net_device *dev) 692static void lec_set_multicast_list(struct net_device *dev)
660{ 693{
661 /* by default, all multicast frames arrive over the bus. 694 /*
662 * eventually support selective multicast service 695 * by default, all multicast frames arrive over the bus.
663 */ 696 * eventually support selective multicast service
664 return; 697 */
698 return;
665} 699}
666 700
667static void 701static void lec_init(struct net_device *dev)
668lec_init(struct net_device *dev)
669{ 702{
670 dev->change_mtu = lec_change_mtu; 703 dev->change_mtu = lec_change_mtu;
671 dev->open = lec_open; 704 dev->open = lec_open;
672 dev->stop = lec_close; 705 dev->stop = lec_close;
673 dev->hard_start_xmit = lec_start_xmit; 706 dev->hard_start_xmit = lec_start_xmit;
674 dev->tx_timeout = lec_tx_timeout; 707 dev->tx_timeout = lec_tx_timeout;
675 708
676 dev->get_stats = lec_get_stats; 709 dev->get_stats = lec_get_stats;
677 dev->set_multicast_list = lec_set_multicast_list; 710 dev->set_multicast_list = lec_set_multicast_list;
678 dev->do_ioctl = NULL; 711 dev->do_ioctl = NULL;
679 printk("%s: Initialized!\n",dev->name); 712 printk("%s: Initialized!\n", dev->name);
680 return; 713 return;
681} 714}
682 715
683static unsigned char lec_ctrl_magic[] = { 716static unsigned char lec_ctrl_magic[] = {
684 0xff, 717 0xff,
685 0x00, 718 0x00,
686 0x01, 719 0x01,
687 0x01 }; 720 0x01
721};
688 722
689#define LEC_DATA_DIRECT_8023 2 723#define LEC_DATA_DIRECT_8023 2
690#define LEC_DATA_DIRECT_8025 3 724#define LEC_DATA_DIRECT_8025 3
691 725
692static int lec_is_data_direct(struct atm_vcc *vcc) 726static int lec_is_data_direct(struct atm_vcc *vcc)
693{ 727{
694 return ((vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8023) || 728 return ((vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8023) ||
695 (vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8025)); 729 (vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8025));
696} 730}
697 731
698static void 732static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
699lec_push(struct atm_vcc *vcc, struct sk_buff *skb)
700{ 733{
701 unsigned long flags; 734 unsigned long flags;
702 struct net_device *dev = (struct net_device *)vcc->proto_data; 735 struct net_device *dev = (struct net_device *)vcc->proto_data;
703 struct lec_priv *priv = (struct lec_priv *)dev->priv; 736 struct lec_priv *priv = (struct lec_priv *)dev->priv;
704 737
705#if DUMP_PACKETS >0 738#if DUMP_PACKETS >0
706 int i=0; 739 int i = 0;
707 char buf[300]; 740 char buf[300];
708 741
709 printk("%s: lec_push vcc vpi:%d vci:%d\n", dev->name, 742 printk("%s: lec_push vcc vpi:%d vci:%d\n", dev->name,
710 vcc->vpi, vcc->vci); 743 vcc->vpi, vcc->vci);
711#endif 744#endif
712 if (!skb) { 745 if (!skb) {
713 DPRINTK("%s: null skb\n",dev->name); 746 DPRINTK("%s: null skb\n", dev->name);
714 lec_vcc_close(priv, vcc); 747 lec_vcc_close(priv, vcc);
715 return; 748 return;
716 } 749 }
717#if DUMP_PACKETS > 0 750#if DUMP_PACKETS > 0
718 printk("%s: rcv datalen:%ld lecid:%4.4x\n", dev->name, 751 printk("%s: rcv datalen:%ld lecid:%4.4x\n", dev->name,
719 skb->len, priv->lecid); 752 skb->len, priv->lecid);
720#if DUMP_PACKETS >= 2 753#if DUMP_PACKETS >= 2
721 for(i=0;i<skb->len && i <99;i++) { 754 for (i = 0; i < skb->len && i < 99; i++) {
722 sprintf(buf+i*3,"%2.2x ",0xff&skb->data[i]); 755 sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]);
723 } 756 }
724#elif DUMP_PACKETS >= 1 757#elif DUMP_PACKETS >= 1
725 for(i=0;i<skb->len && i < 30;i++) { 758 for (i = 0; i < skb->len && i < 30; i++) {
726 sprintf(buf+i*3,"%2.2x ", 0xff&skb->data[i]); 759 sprintf(buf + i * 3, "%2.2x ", 0xff & skb->data[i]);
727 } 760 }
728#endif /* DUMP_PACKETS >= 1 */ 761#endif /* DUMP_PACKETS >= 1 */
729 if (i==skb->len) 762 if (i == skb->len)
730 printk("%s\n",buf); 763 printk("%s\n", buf);
731 else 764 else
732 printk("%s...\n",buf); 765 printk("%s...\n", buf);
733#endif /* DUMP_PACKETS > 0 */ 766#endif /* DUMP_PACKETS > 0 */
734 if (memcmp(skb->data, lec_ctrl_magic, 4) ==0) { /* Control frame, to daemon*/ 767 if (memcmp(skb->data, lec_ctrl_magic, 4) == 0) { /* Control frame, to daemon */
735 struct sock *sk = sk_atm(vcc); 768 struct sock *sk = sk_atm(vcc);
736 769
737 DPRINTK("%s: To daemon\n",dev->name); 770 DPRINTK("%s: To daemon\n", dev->name);
738 skb_queue_tail(&sk->sk_receive_queue, skb); 771 skb_queue_tail(&sk->sk_receive_queue, skb);
739 sk->sk_data_ready(sk, skb->len); 772 sk->sk_data_ready(sk, skb->len);
740 } else { /* Data frame, queue to protocol handlers */ 773 } else { /* Data frame, queue to protocol handlers */
741 struct lec_arp_table *entry; 774 struct lec_arp_table *entry;
742 unsigned char *src, *dst; 775 unsigned char *src, *dst;
743 776
744 atm_return(vcc,skb->truesize); 777 atm_return(vcc, skb->truesize);
745 if (*(uint16_t *)skb->data == htons(priv->lecid) || 778 if (*(uint16_t *) skb->data == htons(priv->lecid) ||
746 !priv->lecd || 779 !priv->lecd || !(dev->flags & IFF_UP)) {
747 !(dev->flags & IFF_UP)) { 780 /*
748 /* Probably looping back, or if lecd is missing, 781 * Probably looping back, or if lecd is missing,
749 lecd has gone down */ 782 * lecd has gone down
750 DPRINTK("Ignoring frame...\n"); 783 */
751 dev_kfree_skb(skb); 784 DPRINTK("Ignoring frame...\n");
752 return; 785 dev_kfree_skb(skb);
753 } 786 return;
787 }
754#ifdef CONFIG_TR 788#ifdef CONFIG_TR
755 if (priv->is_trdev) 789 if (priv->is_trdev)
756 dst = ((struct lecdatahdr_8025 *) skb->data)->h_dest; 790 dst = ((struct lecdatahdr_8025 *)skb->data)->h_dest;
757 else 791 else
758#endif 792#endif
759 dst = ((struct lecdatahdr_8023 *) skb->data)->h_dest; 793 dst = ((struct lecdatahdr_8023 *)skb->data)->h_dest;
760 794
761 /* If this is a Data Direct VCC, and the VCC does not match 795 /*
796 * If this is a Data Direct VCC, and the VCC does not match
762 * the LE_ARP cache entry, delete the LE_ARP cache entry. 797 * the LE_ARP cache entry, delete the LE_ARP cache entry.
763 */ 798 */
764 spin_lock_irqsave(&priv->lec_arp_lock, flags); 799 spin_lock_irqsave(&priv->lec_arp_lock, flags);
765 if (lec_is_data_direct(vcc)) { 800 if (lec_is_data_direct(vcc)) {
766#ifdef CONFIG_TR 801#ifdef CONFIG_TR
767 if (priv->is_trdev) 802 if (priv->is_trdev)
768 src = ((struct lecdatahdr_8025 *) skb->data)->h_source; 803 src =
804 ((struct lecdatahdr_8025 *)skb->data)->
805 h_source;
769 else 806 else
770#endif 807#endif
771 src = ((struct lecdatahdr_8023 *) skb->data)->h_source; 808 src =
809 ((struct lecdatahdr_8023 *)skb->data)->
810 h_source;
772 entry = lec_arp_find(priv, src); 811 entry = lec_arp_find(priv, src);
773 if (entry && entry->vcc != vcc) { 812 if (entry && entry->vcc != vcc) {
774 lec_arp_remove(priv, entry); 813 lec_arp_remove(priv, entry);
775 kfree(entry); 814 lec_arp_put(entry);
776 } 815 }
777 } 816 }
778 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); 817 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
779 818
780 if (!(dst[0]&0x01) && /* Never filter Multi/Broadcast */ 819 if (!(dst[0] & 0x01) && /* Never filter Multi/Broadcast */
781 !priv->is_proxy && /* Proxy wants all the packets */ 820 !priv->is_proxy && /* Proxy wants all the packets */
782 memcmp(dst, dev->dev_addr, dev->addr_len)) { 821 memcmp(dst, dev->dev_addr, dev->addr_len)) {
783 dev_kfree_skb(skb); 822 dev_kfree_skb(skb);
784 return; 823 return;
785 } 824 }
786 if (priv->lec_arp_empty_ones) { 825 if (!hlist_empty(&priv->lec_arp_empty_ones)) {
787 lec_arp_check_empties(priv, vcc, skb); 826 lec_arp_check_empties(priv, vcc, skb);
788 } 827 }
789 skb->dev = dev; 828 skb->dev = dev;
790 skb_pull(skb, 2); /* skip lec_id */ 829 skb_pull(skb, 2); /* skip lec_id */
791#ifdef CONFIG_TR 830#ifdef CONFIG_TR
792 if (priv->is_trdev) skb->protocol = tr_type_trans(skb, dev); 831 if (priv->is_trdev)
793 else 832 skb->protocol = tr_type_trans(skb, dev);
833 else
794#endif 834#endif
795 skb->protocol = eth_type_trans(skb, dev); 835 skb->protocol = eth_type_trans(skb, dev);
796 priv->stats.rx_packets++; 836 priv->stats.rx_packets++;
797 priv->stats.rx_bytes += skb->len; 837 priv->stats.rx_bytes += skb->len;
798 memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data)); 838 memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data));
799 netif_rx(skb); 839 netif_rx(skb);
800 } 840 }
801} 841}
802 842
803static void 843static void lec_pop(struct atm_vcc *vcc, struct sk_buff *skb)
804lec_pop(struct atm_vcc *vcc, struct sk_buff *skb)
805{ 844{
806 struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc); 845 struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc);
807 struct net_device *dev = skb->dev; 846 struct net_device *dev = skb->dev;
@@ -820,123 +859,121 @@ lec_pop(struct atm_vcc *vcc, struct sk_buff *skb)
820 } 859 }
821} 860}
822 861
823static int 862static int lec_vcc_attach(struct atm_vcc *vcc, void __user *arg)
824lec_vcc_attach(struct atm_vcc *vcc, void __user *arg)
825{ 863{
826 struct lec_vcc_priv *vpriv; 864 struct lec_vcc_priv *vpriv;
827 int bytes_left; 865 int bytes_left;
828 struct atmlec_ioc ioc_data; 866 struct atmlec_ioc ioc_data;
829 867
830 /* Lecd must be up in this case */ 868 /* Lecd must be up in this case */
831 bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmlec_ioc)); 869 bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmlec_ioc));
832 if (bytes_left != 0) { 870 if (bytes_left != 0) {
833 printk("lec: lec_vcc_attach, copy from user failed for %d bytes\n", 871 printk
834 bytes_left); 872 ("lec: lec_vcc_attach, copy from user failed for %d bytes\n",
835 } 873 bytes_left);
836 if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF || 874 }
837 !dev_lec[ioc_data.dev_num]) 875 if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF ||
838 return -EINVAL; 876 !dev_lec[ioc_data.dev_num])
877 return -EINVAL;
839 if (!(vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL))) 878 if (!(vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL)))
840 return -ENOMEM; 879 return -ENOMEM;
841 vpriv->xoff = 0; 880 vpriv->xoff = 0;
842 vpriv->old_pop = vcc->pop; 881 vpriv->old_pop = vcc->pop;
843 vcc->user_back = vpriv; 882 vcc->user_back = vpriv;
844 vcc->pop = lec_pop; 883 vcc->pop = lec_pop;
845 lec_vcc_added(dev_lec[ioc_data.dev_num]->priv, 884 lec_vcc_added(dev_lec[ioc_data.dev_num]->priv,
846 &ioc_data, vcc, vcc->push); 885 &ioc_data, vcc, vcc->push);
847 vcc->proto_data = dev_lec[ioc_data.dev_num]; 886 vcc->proto_data = dev_lec[ioc_data.dev_num];
848 vcc->push = lec_push; 887 vcc->push = lec_push;
849 return 0; 888 return 0;
850} 889}
851 890
852static int 891static int lec_mcast_attach(struct atm_vcc *vcc, int arg)
853lec_mcast_attach(struct atm_vcc *vcc, int arg)
854{ 892{
855 if (arg <0 || arg >= MAX_LEC_ITF || !dev_lec[arg]) 893 if (arg < 0 || arg >= MAX_LEC_ITF || !dev_lec[arg])
856 return -EINVAL; 894 return -EINVAL;
857 vcc->proto_data = dev_lec[arg]; 895 vcc->proto_data = dev_lec[arg];
858 return (lec_mcast_make((struct lec_priv*)dev_lec[arg]->priv, vcc)); 896 return (lec_mcast_make((struct lec_priv *)dev_lec[arg]->priv, vcc));
859} 897}
860 898
861/* Initialize device. */ 899/* Initialize device. */
862static int 900static int lecd_attach(struct atm_vcc *vcc, int arg)
863lecd_attach(struct atm_vcc *vcc, int arg) 901{
864{ 902 int i;
865 int i; 903 struct lec_priv *priv;
866 struct lec_priv *priv; 904
867 905 if (arg < 0)
868 if (arg<0) 906 i = 0;
869 i = 0; 907 else
870 else 908 i = arg;
871 i = arg;
872#ifdef CONFIG_TR 909#ifdef CONFIG_TR
873 if (arg >= MAX_LEC_ITF) 910 if (arg >= MAX_LEC_ITF)
874 return -EINVAL; 911 return -EINVAL;
875#else /* Reserve the top NUM_TR_DEVS for TR */ 912#else /* Reserve the top NUM_TR_DEVS for TR */
876 if (arg >= (MAX_LEC_ITF-NUM_TR_DEVS)) 913 if (arg >= (MAX_LEC_ITF - NUM_TR_DEVS))
877 return -EINVAL; 914 return -EINVAL;
878#endif 915#endif
879 if (!dev_lec[i]) { 916 if (!dev_lec[i]) {
880 int is_trdev, size; 917 int is_trdev, size;
881 918
882 is_trdev = 0; 919 is_trdev = 0;
883 if (i >= (MAX_LEC_ITF - NUM_TR_DEVS)) 920 if (i >= (MAX_LEC_ITF - NUM_TR_DEVS))
884 is_trdev = 1; 921 is_trdev = 1;
885 922
886 size = sizeof(struct lec_priv); 923 size = sizeof(struct lec_priv);
887#ifdef CONFIG_TR 924#ifdef CONFIG_TR
888 if (is_trdev) 925 if (is_trdev)
889 dev_lec[i] = alloc_trdev(size); 926 dev_lec[i] = alloc_trdev(size);
890 else 927 else
891#endif 928#endif
892 dev_lec[i] = alloc_etherdev(size); 929 dev_lec[i] = alloc_etherdev(size);
893 if (!dev_lec[i]) 930 if (!dev_lec[i])
894 return -ENOMEM; 931 return -ENOMEM;
895 snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i); 932 snprintf(dev_lec[i]->name, IFNAMSIZ, "lec%d", i);
896 if (register_netdev(dev_lec[i])) { 933 if (register_netdev(dev_lec[i])) {
897 free_netdev(dev_lec[i]); 934 free_netdev(dev_lec[i]);
898 return -EINVAL; 935 return -EINVAL;
899 } 936 }
900 937
901 priv = dev_lec[i]->priv; 938 priv = dev_lec[i]->priv;
902 priv->is_trdev = is_trdev; 939 priv->is_trdev = is_trdev;
903 lec_init(dev_lec[i]); 940 lec_init(dev_lec[i]);
904 } else { 941 } else {
905 priv = dev_lec[i]->priv; 942 priv = dev_lec[i]->priv;
906 if (priv->lecd) 943 if (priv->lecd)
907 return -EADDRINUSE; 944 return -EADDRINUSE;
908 } 945 }
909 lec_arp_init(priv); 946 lec_arp_init(priv);
910 priv->itfnum = i; /* LANE2 addition */ 947 priv->itfnum = i; /* LANE2 addition */
911 priv->lecd = vcc; 948 priv->lecd = vcc;
912 vcc->dev = &lecatm_dev; 949 vcc->dev = &lecatm_dev;
913 vcc_insert_socket(sk_atm(vcc)); 950 vcc_insert_socket(sk_atm(vcc));
914 951
915 vcc->proto_data = dev_lec[i]; 952 vcc->proto_data = dev_lec[i];
916 set_bit(ATM_VF_META,&vcc->flags); 953 set_bit(ATM_VF_META, &vcc->flags);
917 set_bit(ATM_VF_READY,&vcc->flags); 954 set_bit(ATM_VF_READY, &vcc->flags);
918 955
919 /* Set default values to these variables */ 956 /* Set default values to these variables */
920 priv->maximum_unknown_frame_count = 1; 957 priv->maximum_unknown_frame_count = 1;
921 priv->max_unknown_frame_time = (1*HZ); 958 priv->max_unknown_frame_time = (1 * HZ);
922 priv->vcc_timeout_period = (1200*HZ); 959 priv->vcc_timeout_period = (1200 * HZ);
923 priv->max_retry_count = 1; 960 priv->max_retry_count = 1;
924 priv->aging_time = (300*HZ); 961 priv->aging_time = (300 * HZ);
925 priv->forward_delay_time = (15*HZ); 962 priv->forward_delay_time = (15 * HZ);
926 priv->topology_change = 0; 963 priv->topology_change = 0;
927 priv->arp_response_time = (1*HZ); 964 priv->arp_response_time = (1 * HZ);
928 priv->flush_timeout = (4*HZ); 965 priv->flush_timeout = (4 * HZ);
929 priv->path_switching_delay = (6*HZ); 966 priv->path_switching_delay = (6 * HZ);
930 967
931 if (dev_lec[i]->flags & IFF_UP) { 968 if (dev_lec[i]->flags & IFF_UP) {
932 netif_start_queue(dev_lec[i]); 969 netif_start_queue(dev_lec[i]);
933 } 970 }
934 __module_get(THIS_MODULE); 971 __module_get(THIS_MODULE);
935 return i; 972 return i;
936} 973}
937 974
938#ifdef CONFIG_PROC_FS 975#ifdef CONFIG_PROC_FS
939static char* lec_arp_get_status_string(unsigned char status) 976static char *lec_arp_get_status_string(unsigned char status)
940{ 977{
941 static char *lec_arp_status_string[] = { 978 static char *lec_arp_status_string[] = {
942 "ESI_UNKNOWN ", 979 "ESI_UNKNOWN ",
@@ -966,52 +1003,54 @@ static void lec_info(struct seq_file *seq, struct lec_arp_table *entry)
966 if (entry->vcc) 1003 if (entry->vcc)
967 seq_printf(seq, "%3d %3d ", entry->vcc->vpi, entry->vcc->vci); 1004 seq_printf(seq, "%3d %3d ", entry->vcc->vpi, entry->vcc->vci);
968 else 1005 else
969 seq_printf(seq, " "); 1006 seq_printf(seq, " ");
970 if (entry->recv_vcc) { 1007 if (entry->recv_vcc) {
971 seq_printf(seq, " %3d %3d", entry->recv_vcc->vpi, 1008 seq_printf(seq, " %3d %3d", entry->recv_vcc->vpi,
972 entry->recv_vcc->vci); 1009 entry->recv_vcc->vci);
973 } 1010 }
974 seq_putc(seq, '\n'); 1011 seq_putc(seq, '\n');
975} 1012}
976 1013
977
978struct lec_state { 1014struct lec_state {
979 unsigned long flags; 1015 unsigned long flags;
980 struct lec_priv *locked; 1016 struct lec_priv *locked;
981 struct lec_arp_table *entry; 1017 struct hlist_node *node;
982 struct net_device *dev; 1018 struct net_device *dev;
983 int itf; 1019 int itf;
984 int arp_table; 1020 int arp_table;
985 int misc_table; 1021 int misc_table;
986}; 1022};
987 1023
988static void *lec_tbl_walk(struct lec_state *state, struct lec_arp_table *tbl, 1024static void *lec_tbl_walk(struct lec_state *state, struct hlist_head *tbl,
989 loff_t *l) 1025 loff_t *l)
990{ 1026{
991 struct lec_arp_table *e = state->entry; 1027 struct hlist_node *e = state->node;
1028 struct lec_arp_table *tmp;
992 1029
993 if (!e) 1030 if (!e)
994 e = tbl; 1031 e = tbl->first;
995 if (e == (void *)1) { 1032 if (e == (void *)1) {
996 e = tbl; 1033 e = tbl->first;
997 --*l; 1034 --*l;
998 } 1035 }
999 for (; e; e = e->next) { 1036
1037 hlist_for_each_entry_from(tmp, e, next) {
1000 if (--*l < 0) 1038 if (--*l < 0)
1001 break; 1039 break;
1002 } 1040 }
1003 state->entry = e; 1041 state->node = e;
1042
1004 return (*l < 0) ? state : NULL; 1043 return (*l < 0) ? state : NULL;
1005} 1044}
1006 1045
1007static void *lec_arp_walk(struct lec_state *state, loff_t *l, 1046static void *lec_arp_walk(struct lec_state *state, loff_t *l,
1008 struct lec_priv *priv) 1047 struct lec_priv *priv)
1009{ 1048{
1010 void *v = NULL; 1049 void *v = NULL;
1011 int p; 1050 int p;
1012 1051
1013 for (p = state->arp_table; p < LEC_ARP_TABLE_SIZE; p++) { 1052 for (p = state->arp_table; p < LEC_ARP_TABLE_SIZE; p++) {
1014 v = lec_tbl_walk(state, priv->lec_arp_tables[p], l); 1053 v = lec_tbl_walk(state, &priv->lec_arp_tables[p], l);
1015 if (v) 1054 if (v)
1016 break; 1055 break;
1017 } 1056 }
@@ -1022,10 +1061,10 @@ static void *lec_arp_walk(struct lec_state *state, loff_t *l,
1022static void *lec_misc_walk(struct lec_state *state, loff_t *l, 1061static void *lec_misc_walk(struct lec_state *state, loff_t *l,
1023 struct lec_priv *priv) 1062 struct lec_priv *priv)
1024{ 1063{
1025 struct lec_arp_table *lec_misc_tables[] = { 1064 struct hlist_head *lec_misc_tables[] = {
1026 priv->lec_arp_empty_ones, 1065 &priv->lec_arp_empty_ones,
1027 priv->lec_no_forward, 1066 &priv->lec_no_forward,
1028 priv->mcast_fwds 1067 &priv->mcast_fwds
1029 }; 1068 };
1030 void *v = NULL; 1069 void *v = NULL;
1031 int q; 1070 int q;
@@ -1046,8 +1085,7 @@ static void *lec_priv_walk(struct lec_state *state, loff_t *l,
1046 state->locked = priv; 1085 state->locked = priv;
1047 spin_lock_irqsave(&priv->lec_arp_lock, state->flags); 1086 spin_lock_irqsave(&priv->lec_arp_lock, state->flags);
1048 } 1087 }
1049 if (!lec_arp_walk(state, l, priv) && 1088 if (!lec_arp_walk(state, l, priv) && !lec_misc_walk(state, l, priv)) {
1050 !lec_misc_walk(state, l, priv)) {
1051 spin_unlock_irqrestore(&priv->lec_arp_lock, state->flags); 1089 spin_unlock_irqrestore(&priv->lec_arp_lock, state->flags);
1052 state->locked = NULL; 1090 state->locked = NULL;
1053 /* Partial state reset for the next time we get called */ 1091 /* Partial state reset for the next time we get called */
@@ -1081,7 +1119,7 @@ static void *lec_get_idx(struct lec_state *state, loff_t l)
1081 if (v) 1119 if (v)
1082 break; 1120 break;
1083 } 1121 }
1084 return v; 1122 return v;
1085} 1123}
1086 1124
1087static void *lec_seq_start(struct seq_file *seq, loff_t *pos) 1125static void *lec_seq_start(struct seq_file *seq, loff_t *pos)
@@ -1093,9 +1131,9 @@ static void *lec_seq_start(struct seq_file *seq, loff_t *pos)
1093 state->locked = NULL; 1131 state->locked = NULL;
1094 state->arp_table = 0; 1132 state->arp_table = 0;
1095 state->misc_table = 0; 1133 state->misc_table = 0;
1096 state->entry = (void *)1; 1134 state->node = (void *)1;
1097 1135
1098 return *pos ? lec_get_idx(state, *pos) : (void*)1; 1136 return *pos ? lec_get_idx(state, *pos) : (void *)1;
1099} 1137}
1100 1138
1101static void lec_seq_stop(struct seq_file *seq, void *v) 1139static void lec_seq_stop(struct seq_file *seq, void *v)
@@ -1120,27 +1158,28 @@ static void *lec_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1120 1158
1121static int lec_seq_show(struct seq_file *seq, void *v) 1159static int lec_seq_show(struct seq_file *seq, void *v)
1122{ 1160{
1123 static char lec_banner[] = "Itf MAC ATM destination" 1161 static char lec_banner[] = "Itf MAC ATM destination"
1124 " Status Flags " 1162 " Status Flags "
1125 "VPI/VCI Recv VPI/VCI\n"; 1163 "VPI/VCI Recv VPI/VCI\n";
1126 1164
1127 if (v == (void *)1) 1165 if (v == (void *)1)
1128 seq_puts(seq, lec_banner); 1166 seq_puts(seq, lec_banner);
1129 else { 1167 else {
1130 struct lec_state *state = seq->private; 1168 struct lec_state *state = seq->private;
1131 struct net_device *dev = state->dev; 1169 struct net_device *dev = state->dev;
1170 struct lec_arp_table *entry = hlist_entry(state->node, struct lec_arp_table, next);
1132 1171
1133 seq_printf(seq, "%s ", dev->name); 1172 seq_printf(seq, "%s ", dev->name);
1134 lec_info(seq, state->entry); 1173 lec_info(seq, entry);
1135 } 1174 }
1136 return 0; 1175 return 0;
1137} 1176}
1138 1177
1139static struct seq_operations lec_seq_ops = { 1178static struct seq_operations lec_seq_ops = {
1140 .start = lec_seq_start, 1179 .start = lec_seq_start,
1141 .next = lec_seq_next, 1180 .next = lec_seq_next,
1142 .stop = lec_seq_stop, 1181 .stop = lec_seq_stop,
1143 .show = lec_seq_show, 1182 .show = lec_seq_show,
1144}; 1183};
1145 1184
1146static int lec_seq_open(struct inode *inode, struct file *file) 1185static int lec_seq_open(struct inode *inode, struct file *file)
@@ -1174,11 +1213,11 @@ static int lec_seq_release(struct inode *inode, struct file *file)
1174} 1213}
1175 1214
1176static struct file_operations lec_seq_fops = { 1215static struct file_operations lec_seq_fops = {
1177 .owner = THIS_MODULE, 1216 .owner = THIS_MODULE,
1178 .open = lec_seq_open, 1217 .open = lec_seq_open,
1179 .read = seq_read, 1218 .read = seq_read,
1180 .llseek = seq_lseek, 1219 .llseek = seq_lseek,
1181 .release = lec_seq_release, 1220 .release = lec_seq_release,
1182}; 1221};
1183#endif 1222#endif
1184 1223
@@ -1186,38 +1225,38 @@ static int lane_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1186{ 1225{
1187 struct atm_vcc *vcc = ATM_SD(sock); 1226 struct atm_vcc *vcc = ATM_SD(sock);
1188 int err = 0; 1227 int err = 0;
1189 1228
1190 switch (cmd) { 1229 switch (cmd) {
1191 case ATMLEC_CTRL: 1230 case ATMLEC_CTRL:
1192 case ATMLEC_MCAST: 1231 case ATMLEC_MCAST:
1193 case ATMLEC_DATA: 1232 case ATMLEC_DATA:
1194 if (!capable(CAP_NET_ADMIN)) 1233 if (!capable(CAP_NET_ADMIN))
1195 return -EPERM; 1234 return -EPERM;
1196 break; 1235 break;
1197 default: 1236 default:
1198 return -ENOIOCTLCMD; 1237 return -ENOIOCTLCMD;
1199 } 1238 }
1200 1239
1201 switch (cmd) { 1240 switch (cmd) {
1202 case ATMLEC_CTRL: 1241 case ATMLEC_CTRL:
1203 err = lecd_attach(vcc, (int) arg); 1242 err = lecd_attach(vcc, (int)arg);
1204 if (err >= 0) 1243 if (err >= 0)
1205 sock->state = SS_CONNECTED; 1244 sock->state = SS_CONNECTED;
1206 break; 1245 break;
1207 case ATMLEC_MCAST: 1246 case ATMLEC_MCAST:
1208 err = lec_mcast_attach(vcc, (int) arg); 1247 err = lec_mcast_attach(vcc, (int)arg);
1209 break; 1248 break;
1210 case ATMLEC_DATA: 1249 case ATMLEC_DATA:
1211 err = lec_vcc_attach(vcc, (void __user *) arg); 1250 err = lec_vcc_attach(vcc, (void __user *)arg);
1212 break; 1251 break;
1213 } 1252 }
1214 1253
1215 return err; 1254 return err;
1216} 1255}
1217 1256
1218static struct atm_ioctl lane_ioctl_ops = { 1257static struct atm_ioctl lane_ioctl_ops = {
1219 .owner = THIS_MODULE, 1258 .owner = THIS_MODULE,
1220 .ioctl = lane_ioctl, 1259 .ioctl = lane_ioctl,
1221}; 1260};
1222 1261
1223static int __init lane_module_init(void) 1262static int __init lane_module_init(void)
@@ -1231,29 +1270,29 @@ static int __init lane_module_init(void)
1231#endif 1270#endif
1232 1271
1233 register_atm_ioctl(&lane_ioctl_ops); 1272 register_atm_ioctl(&lane_ioctl_ops);
1234 printk("lec.c: " __DATE__ " " __TIME__ " initialized\n"); 1273 printk("lec.c: " __DATE__ " " __TIME__ " initialized\n");
1235 return 0; 1274 return 0;
1236} 1275}
1237 1276
1238static void __exit lane_module_cleanup(void) 1277static void __exit lane_module_cleanup(void)
1239{ 1278{
1240 int i; 1279 int i;
1241 struct lec_priv *priv; 1280 struct lec_priv *priv;
1242 1281
1243 remove_proc_entry("lec", atm_proc_root); 1282 remove_proc_entry("lec", atm_proc_root);
1244 1283
1245 deregister_atm_ioctl(&lane_ioctl_ops); 1284 deregister_atm_ioctl(&lane_ioctl_ops);
1246 1285
1247 for (i = 0; i < MAX_LEC_ITF; i++) { 1286 for (i = 0; i < MAX_LEC_ITF; i++) {
1248 if (dev_lec[i] != NULL) { 1287 if (dev_lec[i] != NULL) {
1249 priv = (struct lec_priv *)dev_lec[i]->priv; 1288 priv = (struct lec_priv *)dev_lec[i]->priv;
1250 unregister_netdev(dev_lec[i]); 1289 unregister_netdev(dev_lec[i]);
1251 free_netdev(dev_lec[i]); 1290 free_netdev(dev_lec[i]);
1252 dev_lec[i] = NULL; 1291 dev_lec[i] = NULL;
1253 } 1292 }
1254 } 1293 }
1255 1294
1256 return; 1295 return;
1257} 1296}
1258 1297
1259module_init(lane_module_init); 1298module_init(lane_module_init);
@@ -1267,34 +1306,34 @@ module_exit(lane_module_cleanup);
1267 * If dst_mac == NULL, targetless LE_ARP will be sent 1306 * If dst_mac == NULL, targetless LE_ARP will be sent
1268 */ 1307 */
1269static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force, 1308static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force,
1270 u8 **tlvs, u32 *sizeoftlvs) 1309 u8 **tlvs, u32 *sizeoftlvs)
1271{ 1310{
1272 unsigned long flags; 1311 unsigned long flags;
1273 struct lec_priv *priv = (struct lec_priv *)dev->priv; 1312 struct lec_priv *priv = (struct lec_priv *)dev->priv;
1274 struct lec_arp_table *table; 1313 struct lec_arp_table *table;
1275 struct sk_buff *skb; 1314 struct sk_buff *skb;
1276 int retval; 1315 int retval;
1277 1316
1278 if (force == 0) { 1317 if (force == 0) {
1279 spin_lock_irqsave(&priv->lec_arp_lock, flags); 1318 spin_lock_irqsave(&priv->lec_arp_lock, flags);
1280 table = lec_arp_find(priv, dst_mac); 1319 table = lec_arp_find(priv, dst_mac);
1281 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); 1320 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
1282 if(table == NULL) 1321 if (table == NULL)
1283 return -1; 1322 return -1;
1284 1323
1285 *tlvs = kmalloc(table->sizeoftlvs, GFP_ATOMIC); 1324 *tlvs = kmalloc(table->sizeoftlvs, GFP_ATOMIC);
1286 if (*tlvs == NULL) 1325 if (*tlvs == NULL)
1287 return -1; 1326 return -1;
1288 1327
1289 memcpy(*tlvs, table->tlvs, table->sizeoftlvs); 1328 memcpy(*tlvs, table->tlvs, table->sizeoftlvs);
1290 *sizeoftlvs = table->sizeoftlvs; 1329 *sizeoftlvs = table->sizeoftlvs;
1291 1330
1292 return 0; 1331 return 0;
1293 } 1332 }
1294 1333
1295 if (sizeoftlvs == NULL) 1334 if (sizeoftlvs == NULL)
1296 retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, NULL); 1335 retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, NULL);
1297 1336
1298 else { 1337 else {
1299 skb = alloc_skb(*sizeoftlvs, GFP_ATOMIC); 1338 skb = alloc_skb(*sizeoftlvs, GFP_ATOMIC);
1300 if (skb == NULL) 1339 if (skb == NULL)
@@ -1303,9 +1342,8 @@ static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force,
1303 memcpy(skb->data, *tlvs, *sizeoftlvs); 1342 memcpy(skb->data, *tlvs, *sizeoftlvs);
1304 retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, skb); 1343 retval = send_to_lecd(priv, l_arp_xmt, dst_mac, NULL, skb);
1305 } 1344 }
1306 return retval; 1345 return retval;
1307} 1346}
1308
1309 1347
1310/* 1348/*
1311 * LANE2: 3.1.4, LE_ASSOCIATE.request 1349 * LANE2: 3.1.4, LE_ASSOCIATE.request
@@ -1314,80 +1352,85 @@ static int lane2_resolve(struct net_device *dev, u8 *dst_mac, int force,
1314 * Returns 1 for success, 0 for failure (out of memory) 1352 * Returns 1 for success, 0 for failure (out of memory)
1315 * 1353 *
1316 */ 1354 */
1317static int lane2_associate_req (struct net_device *dev, u8 *lan_dst, 1355static int lane2_associate_req(struct net_device *dev, u8 *lan_dst,
1318 u8 *tlvs, u32 sizeoftlvs) 1356 u8 *tlvs, u32 sizeoftlvs)
1319{ 1357{
1320 int retval; 1358 int retval;
1321 struct sk_buff *skb; 1359 struct sk_buff *skb;
1322 struct lec_priv *priv = (struct lec_priv*)dev->priv; 1360 struct lec_priv *priv = (struct lec_priv *)dev->priv;
1323 1361
1324 if (compare_ether_addr(lan_dst, dev->dev_addr)) 1362 if (compare_ether_addr(lan_dst, dev->dev_addr))
1325 return (0); /* not our mac address */ 1363 return (0); /* not our mac address */
1326 1364
1327 kfree(priv->tlvs); /* NULL if there was no previous association */ 1365 kfree(priv->tlvs); /* NULL if there was no previous association */
1328 1366
1329 priv->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL); 1367 priv->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL);
1330 if (priv->tlvs == NULL) 1368 if (priv->tlvs == NULL)
1331 return (0); 1369 return (0);
1332 priv->sizeoftlvs = sizeoftlvs; 1370 priv->sizeoftlvs = sizeoftlvs;
1333 memcpy(priv->tlvs, tlvs, sizeoftlvs); 1371 memcpy(priv->tlvs, tlvs, sizeoftlvs);
1334 1372
1335 skb = alloc_skb(sizeoftlvs, GFP_ATOMIC); 1373 skb = alloc_skb(sizeoftlvs, GFP_ATOMIC);
1336 if (skb == NULL) 1374 if (skb == NULL)
1337 return 0; 1375 return 0;
1338 skb->len = sizeoftlvs; 1376 skb->len = sizeoftlvs;
1339 memcpy(skb->data, tlvs, sizeoftlvs); 1377 memcpy(skb->data, tlvs, sizeoftlvs);
1340 retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb); 1378 retval = send_to_lecd(priv, l_associate_req, NULL, NULL, skb);
1341 if (retval != 0) 1379 if (retval != 0)
1342 printk("lec.c: lane2_associate_req() failed\n"); 1380 printk("lec.c: lane2_associate_req() failed\n");
1343 /* If the previous association has changed we must 1381 /*
1344 * somehow notify other LANE entities about the change 1382 * If the previous association has changed we must
1345 */ 1383 * somehow notify other LANE entities about the change
1346 return (1); 1384 */
1385 return (1);
1347} 1386}
1348 1387
1349/* 1388/*
1350 * LANE2: 3.1.5, LE_ASSOCIATE.indication 1389 * LANE2: 3.1.5, LE_ASSOCIATE.indication
1351 * 1390 *
1352 */ 1391 */
1353static void lane2_associate_ind (struct net_device *dev, u8 *mac_addr, 1392static void lane2_associate_ind(struct net_device *dev, u8 *mac_addr,
1354 u8 *tlvs, u32 sizeoftlvs) 1393 u8 *tlvs, u32 sizeoftlvs)
1355{ 1394{
1356#if 0 1395#if 0
1357 int i = 0; 1396 int i = 0;
1358#endif 1397#endif
1359 struct lec_priv *priv = (struct lec_priv *)dev->priv; 1398 struct lec_priv *priv = (struct lec_priv *)dev->priv;
1360#if 0 /* Why have the TLVs in LE_ARP entries since we do not use them? When you 1399#if 0 /*
1361 uncomment this code, make sure the TLVs get freed when entry is killed */ 1400 * Why have the TLVs in LE_ARP entries
1362 struct lec_arp_table *entry = lec_arp_find(priv, mac_addr); 1401 * since we do not use them? When you
1402 * uncomment this code, make sure the
1403 * TLVs get freed when entry is killed
1404 */
1405 struct lec_arp_table *entry = lec_arp_find(priv, mac_addr);
1363 1406
1364 if (entry == NULL) 1407 if (entry == NULL)
1365 return; /* should not happen */ 1408 return; /* should not happen */
1366 1409
1367 kfree(entry->tlvs); 1410 kfree(entry->tlvs);
1368 1411
1369 entry->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL); 1412 entry->tlvs = kmalloc(sizeoftlvs, GFP_KERNEL);
1370 if (entry->tlvs == NULL) 1413 if (entry->tlvs == NULL)
1371 return; 1414 return;
1372 1415
1373 entry->sizeoftlvs = sizeoftlvs; 1416 entry->sizeoftlvs = sizeoftlvs;
1374 memcpy(entry->tlvs, tlvs, sizeoftlvs); 1417 memcpy(entry->tlvs, tlvs, sizeoftlvs);
1375#endif 1418#endif
1376#if 0 1419#if 0
1377 printk("lec.c: lane2_associate_ind()\n"); 1420 printk("lec.c: lane2_associate_ind()\n");
1378 printk("dump of tlvs, sizeoftlvs=%d\n", sizeoftlvs); 1421 printk("dump of tlvs, sizeoftlvs=%d\n", sizeoftlvs);
1379 while (i < sizeoftlvs) 1422 while (i < sizeoftlvs)
1380 printk("%02x ", tlvs[i++]); 1423 printk("%02x ", tlvs[i++]);
1381 1424
1382 printk("\n"); 1425 printk("\n");
1383#endif 1426#endif
1384 1427
1385 /* tell MPOA about the TLVs we saw */ 1428 /* tell MPOA about the TLVs we saw */
1386 if (priv->lane2_ops && priv->lane2_ops->associate_indicator) { 1429 if (priv->lane2_ops && priv->lane2_ops->associate_indicator) {
1387 priv->lane2_ops->associate_indicator(dev, mac_addr, 1430 priv->lane2_ops->associate_indicator(dev, mac_addr,
1388 tlvs, sizeoftlvs); 1431 tlvs, sizeoftlvs);
1389 } 1432 }
1390 return; 1433 return;
1391} 1434}
1392 1435
1393/* 1436/*
@@ -1395,7 +1438,6 @@ static void lane2_associate_ind (struct net_device *dev, u8 *mac_addr,
1395 * 1438 *
1396 * lec_arpc.c was added here when making 1439 * lec_arpc.c was added here when making
1397 * lane client modular. October 1997 1440 * lane client modular. October 1997
1398 *
1399 */ 1441 */
1400 1442
1401#include <linux/types.h> 1443#include <linux/types.h>
@@ -1406,7 +1448,6 @@ static void lane2_associate_ind (struct net_device *dev, u8 *mac_addr,
1406#include <linux/inetdevice.h> 1448#include <linux/inetdevice.h>
1407#include <net/route.h> 1449#include <net/route.h>
1408 1450
1409
1410#if 0 1451#if 0
1411#define DPRINTK(format,args...) 1452#define DPRINTK(format,args...)
1412/* 1453/*
@@ -1417,7 +1458,7 @@ static void lane2_associate_ind (struct net_device *dev, u8 *mac_addr,
1417 1458
1418#define LEC_ARP_REFRESH_INTERVAL (3*HZ) 1459#define LEC_ARP_REFRESH_INTERVAL (3*HZ)
1419 1460
1420static void lec_arp_check_expire(unsigned long data); 1461static void lec_arp_check_expire(void *data);
1421static void lec_arp_expire_arp(unsigned long data); 1462static void lec_arp_expire_arp(unsigned long data);
1422 1463
1423/* 1464/*
@@ -1429,474 +1470,397 @@ static void lec_arp_expire_arp(unsigned long data);
1429/* 1470/*
1430 * Initialization of arp-cache 1471 * Initialization of arp-cache
1431 */ 1472 */
1432static void 1473static void lec_arp_init(struct lec_priv *priv)
1433lec_arp_init(struct lec_priv *priv)
1434{ 1474{
1435 unsigned short i; 1475 unsigned short i;
1436 1476
1437 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { 1477 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
1438 priv->lec_arp_tables[i] = NULL; 1478 INIT_HLIST_HEAD(&priv->lec_arp_tables[i]);
1439 } 1479 }
1480 INIT_HLIST_HEAD(&priv->lec_arp_empty_ones);
1481 INIT_HLIST_HEAD(&priv->lec_no_forward);
1482 INIT_HLIST_HEAD(&priv->mcast_fwds);
1440 spin_lock_init(&priv->lec_arp_lock); 1483 spin_lock_init(&priv->lec_arp_lock);
1441 init_timer(&priv->lec_arp_timer); 1484 INIT_WORK(&priv->lec_arp_work, lec_arp_check_expire, priv);
1442 priv->lec_arp_timer.expires = jiffies + LEC_ARP_REFRESH_INTERVAL; 1485 schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL);
1443 priv->lec_arp_timer.data = (unsigned long)priv;
1444 priv->lec_arp_timer.function = lec_arp_check_expire;
1445 add_timer(&priv->lec_arp_timer);
1446} 1486}
1447 1487
1448static void 1488static void lec_arp_clear_vccs(struct lec_arp_table *entry)
1449lec_arp_clear_vccs(struct lec_arp_table *entry)
1450{ 1489{
1451 if (entry->vcc) { 1490 if (entry->vcc) {
1452 struct atm_vcc *vcc = entry->vcc; 1491 struct atm_vcc *vcc = entry->vcc;
1453 struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc); 1492 struct lec_vcc_priv *vpriv = LEC_VCC_PRIV(vcc);
1454 struct net_device *dev = (struct net_device*) vcc->proto_data; 1493 struct net_device *dev = (struct net_device *)vcc->proto_data;
1455 1494
1456 vcc->pop = vpriv->old_pop; 1495 vcc->pop = vpriv->old_pop;
1457 if (vpriv->xoff) 1496 if (vpriv->xoff)
1458 netif_wake_queue(dev); 1497 netif_wake_queue(dev);
1459 kfree(vpriv); 1498 kfree(vpriv);
1460 vcc->user_back = NULL; 1499 vcc->user_back = NULL;
1461 vcc->push = entry->old_push; 1500 vcc->push = entry->old_push;
1462 vcc_release_async(vcc, -EPIPE); 1501 vcc_release_async(vcc, -EPIPE);
1463 vcc = NULL; 1502 entry->vcc = NULL;
1464 } 1503 }
1465 if (entry->recv_vcc) { 1504 if (entry->recv_vcc) {
1466 entry->recv_vcc->push = entry->old_recv_push; 1505 entry->recv_vcc->push = entry->old_recv_push;
1467 vcc_release_async(entry->recv_vcc, -EPIPE); 1506 vcc_release_async(entry->recv_vcc, -EPIPE);
1468 entry->recv_vcc = NULL; 1507 entry->recv_vcc = NULL;
1469 } 1508 }
1470} 1509}
1471 1510
1472/* 1511/*
1473 * Insert entry to lec_arp_table 1512 * Insert entry to lec_arp_table
1474 * LANE2: Add to the end of the list to satisfy 8.1.13 1513 * LANE2: Add to the end of the list to satisfy 8.1.13
1475 */ 1514 */
1476static inline void 1515static inline void
1477lec_arp_add(struct lec_priv *priv, struct lec_arp_table *to_add) 1516lec_arp_add(struct lec_priv *priv, struct lec_arp_table *entry)
1478{ 1517{
1479 unsigned short place; 1518 struct hlist_head *tmp;
1480 struct lec_arp_table *tmp; 1519
1481 1520 tmp = &priv->lec_arp_tables[HASH(entry->mac_addr[ETH_ALEN - 1])];
1482 place = HASH(to_add->mac_addr[ETH_ALEN-1]); 1521 hlist_add_head(&entry->next, tmp);
1483 tmp = priv->lec_arp_tables[place]; 1522
1484 to_add->next = NULL; 1523 DPRINTK("LEC_ARP: Added entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n",
1485 if (tmp == NULL) 1524 0xff & entry->mac_addr[0], 0xff & entry->mac_addr[1],
1486 priv->lec_arp_tables[place] = to_add; 1525 0xff & entry->mac_addr[2], 0xff & entry->mac_addr[3],
1487 1526 0xff & entry->mac_addr[4], 0xff & entry->mac_addr[5]);
1488 else { /* add to the end */
1489 while (tmp->next)
1490 tmp = tmp->next;
1491 tmp->next = to_add;
1492 }
1493
1494 DPRINTK("LEC_ARP: Added entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n",
1495 0xff&to_add->mac_addr[0], 0xff&to_add->mac_addr[1],
1496 0xff&to_add->mac_addr[2], 0xff&to_add->mac_addr[3],
1497 0xff&to_add->mac_addr[4], 0xff&to_add->mac_addr[5]);
1498} 1527}
1499 1528
1500/* 1529/*
1501 * Remove entry from lec_arp_table 1530 * Remove entry from lec_arp_table
1502 */ 1531 */
1503static int 1532static int
1504lec_arp_remove(struct lec_priv *priv, 1533lec_arp_remove(struct lec_priv *priv, struct lec_arp_table *to_remove)
1505 struct lec_arp_table *to_remove)
1506{ 1534{
1507 unsigned short place; 1535 struct hlist_node *node;
1508 struct lec_arp_table *tmp; 1536 struct lec_arp_table *entry;
1509 int remove_vcc=1; 1537 int i, remove_vcc = 1;
1510 1538
1511 if (!to_remove) { 1539 if (!to_remove) {
1512 return -1; 1540 return -1;
1513 } 1541 }
1514 place = HASH(to_remove->mac_addr[ETH_ALEN-1]); 1542
1515 tmp = priv->lec_arp_tables[place]; 1543 hlist_del(&to_remove->next);
1516 if (tmp == to_remove) { 1544 del_timer(&to_remove->timer);
1517 priv->lec_arp_tables[place] = tmp->next; 1545
1518 } else { 1546 /* If this is the only MAC connected to this VCC, also tear down the VCC */
1519 while(tmp && tmp->next != to_remove) { 1547 if (to_remove->status >= ESI_FLUSH_PENDING) {
1520 tmp = tmp->next; 1548 /*
1521 } 1549 * ESI_FLUSH_PENDING, ESI_FORWARD_DIRECT
1522 if (!tmp) {/* Entry was not found */ 1550 */
1523 return -1; 1551 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
1524 } 1552 hlist_for_each_entry(entry, node, &priv->lec_arp_tables[i], next) {
1525 } 1553 if (memcmp(to_remove->atm_addr,
1526 tmp->next = to_remove->next; 1554 entry->atm_addr, ATM_ESA_LEN) == 0) {
1527 del_timer(&to_remove->timer); 1555 remove_vcc = 0;
1528 1556 break;
1529 /* If this is the only MAC connected to this VCC, also tear down 1557 }
1530 the VCC */ 1558 }
1531 if (to_remove->status >= ESI_FLUSH_PENDING) { 1559 }
1532 /* 1560 if (remove_vcc)
1533 * ESI_FLUSH_PENDING, ESI_FORWARD_DIRECT 1561 lec_arp_clear_vccs(to_remove);
1534 */ 1562 }
1535 for(place = 0; place < LEC_ARP_TABLE_SIZE; place++) { 1563 skb_queue_purge(&to_remove->tx_wait); /* FIXME: good place for this? */
1536 for(tmp = priv->lec_arp_tables[place]; tmp != NULL; tmp = tmp->next) { 1564
1537 if (memcmp(tmp->atm_addr, to_remove->atm_addr, 1565 DPRINTK("LEC_ARP: Removed entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n",
1538 ATM_ESA_LEN)==0) { 1566 0xff & to_remove->mac_addr[0], 0xff & to_remove->mac_addr[1],
1539 remove_vcc=0; 1567 0xff & to_remove->mac_addr[2], 0xff & to_remove->mac_addr[3],
1540 break; 1568 0xff & to_remove->mac_addr[4], 0xff & to_remove->mac_addr[5]);
1541 } 1569 return 0;
1542 }
1543 }
1544 if (remove_vcc)
1545 lec_arp_clear_vccs(to_remove);
1546 }
1547 skb_queue_purge(&to_remove->tx_wait); /* FIXME: good place for this? */
1548
1549 DPRINTK("LEC_ARP: Removed entry:%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n",
1550 0xff&to_remove->mac_addr[0], 0xff&to_remove->mac_addr[1],
1551 0xff&to_remove->mac_addr[2], 0xff&to_remove->mac_addr[3],
1552 0xff&to_remove->mac_addr[4], 0xff&to_remove->mac_addr[5]);
1553 return 0;
1554} 1570}
1555 1571
1556#if DEBUG_ARP_TABLE 1572#if DEBUG_ARP_TABLE
1557static char* 1573static char *get_status_string(unsigned char st)
1558get_status_string(unsigned char st)
1559{ 1574{
1560 switch(st) { 1575 switch (st) {
1561 case ESI_UNKNOWN: 1576 case ESI_UNKNOWN:
1562 return "ESI_UNKNOWN"; 1577 return "ESI_UNKNOWN";
1563 case ESI_ARP_PENDING: 1578 case ESI_ARP_PENDING:
1564 return "ESI_ARP_PENDING"; 1579 return "ESI_ARP_PENDING";
1565 case ESI_VC_PENDING: 1580 case ESI_VC_PENDING:
1566 return "ESI_VC_PENDING"; 1581 return "ESI_VC_PENDING";
1567 case ESI_FLUSH_PENDING: 1582 case ESI_FLUSH_PENDING:
1568 return "ESI_FLUSH_PENDING"; 1583 return "ESI_FLUSH_PENDING";
1569 case ESI_FORWARD_DIRECT: 1584 case ESI_FORWARD_DIRECT:
1570 return "ESI_FORWARD_DIRECT"; 1585 return "ESI_FORWARD_DIRECT";
1571 default: 1586 default:
1572 return "<UNKNOWN>"; 1587 return "<UNKNOWN>";
1573 } 1588 }
1574} 1589}
1575#endif
1576 1590
1577static void 1591static void dump_arp_table(struct lec_priv *priv)
1578dump_arp_table(struct lec_priv *priv)
1579{ 1592{
1580#if DEBUG_ARP_TABLE 1593 struct hlist_node *node;
1581 int i,j, offset; 1594 struct lec_arp_table *rulla;
1582 struct lec_arp_table *rulla; 1595 char buf[256];
1583 char buf[1024]; 1596 int i, j, offset;
1584 struct lec_arp_table **lec_arp_tables = 1597
1585 (struct lec_arp_table **)priv->lec_arp_tables; 1598 printk("Dump %p:\n", priv);
1586 struct lec_arp_table *lec_arp_empty_ones = 1599 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
1587 (struct lec_arp_table *)priv->lec_arp_empty_ones; 1600 hlist_for_each_entry(rulla, node, &priv->lec_arp_tables[i], next) {
1588 struct lec_arp_table *lec_no_forward = 1601 offset = 0;
1589 (struct lec_arp_table *)priv->lec_no_forward; 1602 offset += sprintf(buf, "%d: %p\n", i, rulla);
1590 struct lec_arp_table *mcast_fwds = priv->mcast_fwds; 1603 offset += sprintf(buf + offset, "Mac:");
1591 1604 for (j = 0; j < ETH_ALEN; j++) {
1592 1605 offset += sprintf(buf + offset,
1593 printk("Dump %p:\n",priv); 1606 "%2.2x ",
1594 for (i=0;i<LEC_ARP_TABLE_SIZE;i++) { 1607 rulla->mac_addr[j] & 0xff);
1595 rulla = lec_arp_tables[i]; 1608 }
1596 offset = 0; 1609 offset += sprintf(buf + offset, "Atm:");
1597 offset += sprintf(buf,"%d: %p\n",i, rulla); 1610 for (j = 0; j < ATM_ESA_LEN; j++) {
1598 while (rulla) { 1611 offset += sprintf(buf + offset,
1599 offset += sprintf(buf+offset,"Mac:"); 1612 "%2.2x ",
1600 for(j=0;j<ETH_ALEN;j++) { 1613 rulla->atm_addr[j] & 0xff);
1601 offset+=sprintf(buf+offset, 1614 }
1602 "%2.2x ", 1615 offset += sprintf(buf + offset,
1603 rulla->mac_addr[j]&0xff); 1616 "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
1604 } 1617 rulla->vcc ? rulla->vcc->vpi : 0,
1605 offset +=sprintf(buf+offset,"Atm:"); 1618 rulla->vcc ? rulla->vcc->vci : 0,
1606 for(j=0;j<ATM_ESA_LEN;j++) { 1619 rulla->recv_vcc ? rulla->recv_vcc->
1607 offset+=sprintf(buf+offset, 1620 vpi : 0,
1608 "%2.2x ", 1621 rulla->recv_vcc ? rulla->recv_vcc->
1609 rulla->atm_addr[j]&0xff); 1622 vci : 0, rulla->last_used,
1610 } 1623 rulla->timestamp, rulla->no_tries);
1611 offset+=sprintf(buf+offset, 1624 offset +=
1612 "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", 1625 sprintf(buf + offset,
1613 rulla->vcc?rulla->vcc->vpi:0, 1626 "Flags:%x, Packets_flooded:%x, Status: %s ",
1614 rulla->vcc?rulla->vcc->vci:0, 1627 rulla->flags, rulla->packets_flooded,
1615 rulla->recv_vcc?rulla->recv_vcc->vpi:0, 1628 get_status_string(rulla->status));
1616 rulla->recv_vcc?rulla->recv_vcc->vci:0, 1629 printk("%s\n", buf);
1617 rulla->last_used, 1630 }
1618 rulla->timestamp, rulla->no_tries); 1631 }
1619 offset+=sprintf(buf+offset, 1632
1620 "Flags:%x, Packets_flooded:%x, Status: %s ", 1633 if (!hlist_empty(&priv->lec_no_forward))
1621 rulla->flags, rulla->packets_flooded, 1634 printk("No forward\n");
1622 get_status_string(rulla->status)); 1635 hlist_for_each_entry(rulla, node, &priv->lec_no_forward, next) {
1623 offset+=sprintf(buf+offset,"->%p\n",rulla->next); 1636 offset = 0;
1624 rulla = rulla->next; 1637 offset += sprintf(buf + offset, "Mac:");
1625 } 1638 for (j = 0; j < ETH_ALEN; j++) {
1626 printk("%s",buf); 1639 offset += sprintf(buf + offset, "%2.2x ",
1627 } 1640 rulla->mac_addr[j] & 0xff);
1628 rulla = lec_no_forward; 1641 }
1629 if (rulla) 1642 offset += sprintf(buf + offset, "Atm:");
1630 printk("No forward\n"); 1643 for (j = 0; j < ATM_ESA_LEN; j++) {
1631 while(rulla) { 1644 offset += sprintf(buf + offset, "%2.2x ",
1632 offset=0; 1645 rulla->atm_addr[j] & 0xff);
1633 offset += sprintf(buf+offset,"Mac:"); 1646 }
1634 for(j=0;j<ETH_ALEN;j++) { 1647 offset += sprintf(buf + offset,
1635 offset+=sprintf(buf+offset,"%2.2x ", 1648 "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
1636 rulla->mac_addr[j]&0xff); 1649 rulla->vcc ? rulla->vcc->vpi : 0,
1637 } 1650 rulla->vcc ? rulla->vcc->vci : 0,
1638 offset +=sprintf(buf+offset,"Atm:"); 1651 rulla->recv_vcc ? rulla->recv_vcc->vpi : 0,
1639 for(j=0;j<ATM_ESA_LEN;j++) { 1652 rulla->recv_vcc ? rulla->recv_vcc->vci : 0,
1640 offset+=sprintf(buf+offset,"%2.2x ", 1653 rulla->last_used,
1641 rulla->atm_addr[j]&0xff); 1654 rulla->timestamp, rulla->no_tries);
1642 } 1655 offset += sprintf(buf + offset,
1643 offset+=sprintf(buf+offset, 1656 "Flags:%x, Packets_flooded:%x, Status: %s ",
1644 "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", 1657 rulla->flags, rulla->packets_flooded,
1645 rulla->vcc?rulla->vcc->vpi:0, 1658 get_status_string(rulla->status));
1646 rulla->vcc?rulla->vcc->vci:0, 1659 printk("%s\n", buf);
1647 rulla->recv_vcc?rulla->recv_vcc->vpi:0, 1660 }
1648 rulla->recv_vcc?rulla->recv_vcc->vci:0, 1661
1649 rulla->last_used, 1662 if (!hlist_empty(&priv->lec_arp_empty_ones))
1650 rulla->timestamp, rulla->no_tries); 1663 printk("Empty ones\n");
1651 offset+=sprintf(buf+offset, 1664 hlist_for_each_entry(rulla, node, &priv->lec_arp_empty_ones, next) {
1652 "Flags:%x, Packets_flooded:%x, Status: %s ", 1665 offset = 0;
1653 rulla->flags, rulla->packets_flooded, 1666 offset += sprintf(buf + offset, "Mac:");
1654 get_status_string(rulla->status)); 1667 for (j = 0; j < ETH_ALEN; j++) {
1655 offset+=sprintf(buf+offset,"->%lx\n",(long)rulla->next); 1668 offset += sprintf(buf + offset, "%2.2x ",
1656 rulla = rulla->next; 1669 rulla->mac_addr[j] & 0xff);
1657 printk("%s",buf); 1670 }
1658 } 1671 offset += sprintf(buf + offset, "Atm:");
1659 rulla = lec_arp_empty_ones; 1672 for (j = 0; j < ATM_ESA_LEN; j++) {
1660 if (rulla) 1673 offset += sprintf(buf + offset, "%2.2x ",
1661 printk("Empty ones\n"); 1674 rulla->atm_addr[j] & 0xff);
1662 while(rulla) { 1675 }
1663 offset=0; 1676 offset += sprintf(buf + offset,
1664 offset += sprintf(buf+offset,"Mac:"); 1677 "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
1665 for(j=0;j<ETH_ALEN;j++) { 1678 rulla->vcc ? rulla->vcc->vpi : 0,
1666 offset+=sprintf(buf+offset,"%2.2x ", 1679 rulla->vcc ? rulla->vcc->vci : 0,
1667 rulla->mac_addr[j]&0xff); 1680 rulla->recv_vcc ? rulla->recv_vcc->vpi : 0,
1668 } 1681 rulla->recv_vcc ? rulla->recv_vcc->vci : 0,
1669 offset +=sprintf(buf+offset,"Atm:"); 1682 rulla->last_used,
1670 for(j=0;j<ATM_ESA_LEN;j++) { 1683 rulla->timestamp, rulla->no_tries);
1671 offset+=sprintf(buf+offset,"%2.2x ", 1684 offset += sprintf(buf + offset,
1672 rulla->atm_addr[j]&0xff); 1685 "Flags:%x, Packets_flooded:%x, Status: %s ",
1673 } 1686 rulla->flags, rulla->packets_flooded,
1674 offset+=sprintf(buf+offset, 1687 get_status_string(rulla->status));
1675 "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ", 1688 printk("%s", buf);
1676 rulla->vcc?rulla->vcc->vpi:0, 1689 }
1677 rulla->vcc?rulla->vcc->vci:0, 1690
1678 rulla->recv_vcc?rulla->recv_vcc->vpi:0, 1691 if (!hlist_empty(&priv->mcast_fwds))
1679 rulla->recv_vcc?rulla->recv_vcc->vci:0, 1692 printk("Multicast Forward VCCs\n");
1680 rulla->last_used, 1693 hlist_for_each_entry(rulla, node, &priv->mcast_fwds, next) {
1681 rulla->timestamp, rulla->no_tries); 1694 offset = 0;
1682 offset+=sprintf(buf+offset, 1695 offset += sprintf(buf + offset, "Mac:");
1683 "Flags:%x, Packets_flooded:%x, Status: %s ", 1696 for (j = 0; j < ETH_ALEN; j++) {
1684 rulla->flags, rulla->packets_flooded, 1697 offset += sprintf(buf + offset, "%2.2x ",
1685 get_status_string(rulla->status)); 1698 rulla->mac_addr[j] & 0xff);
1686 offset+=sprintf(buf+offset,"->%lx\n",(long)rulla->next); 1699 }
1687 rulla = rulla->next; 1700 offset += sprintf(buf + offset, "Atm:");
1688 printk("%s",buf); 1701 for (j = 0; j < ATM_ESA_LEN; j++) {
1689 } 1702 offset += sprintf(buf + offset, "%2.2x ",
1690 1703 rulla->atm_addr[j] & 0xff);
1691 rulla = mcast_fwds; 1704 }
1692 if (rulla) 1705 offset += sprintf(buf + offset,
1693 printk("Multicast Forward VCCs\n"); 1706 "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
1694 while(rulla) { 1707 rulla->vcc ? rulla->vcc->vpi : 0,
1695 offset=0; 1708 rulla->vcc ? rulla->vcc->vci : 0,
1696 offset += sprintf(buf+offset,"Mac:"); 1709 rulla->recv_vcc ? rulla->recv_vcc->vpi : 0,
1697 for(j=0;j<ETH_ALEN;j++) { 1710 rulla->recv_vcc ? rulla->recv_vcc->vci : 0,
1698 offset+=sprintf(buf+offset,"%2.2x ", 1711 rulla->last_used,
1699 rulla->mac_addr[j]&0xff); 1712 rulla->timestamp, rulla->no_tries);
1700 } 1713 offset += sprintf(buf + offset,
1701 offset +=sprintf(buf+offset,"Atm:"); 1714 "Flags:%x, Packets_flooded:%x, Status: %s ",
1702 for(j=0;j<ATM_ESA_LEN;j++) { 1715 rulla->flags, rulla->packets_flooded,
1703 offset+=sprintf(buf+offset,"%2.2x ", 1716 get_status_string(rulla->status));
1704 rulla->atm_addr[j]&0xff); 1717 printk("%s\n", buf);
1705 } 1718 }
1706 offset+=sprintf(buf+offset,
1707 "Vcc vpi:%d vci:%d, Recv_vcc vpi:%d vci:%d Last_used:%lx, Timestamp:%lx, No_tries:%d ",
1708 rulla->vcc?rulla->vcc->vpi:0,
1709 rulla->vcc?rulla->vcc->vci:0,
1710 rulla->recv_vcc?rulla->recv_vcc->vpi:0,
1711 rulla->recv_vcc?rulla->recv_vcc->vci:0,
1712 rulla->last_used,
1713 rulla->timestamp, rulla->no_tries);
1714 offset+=sprintf(buf+offset,
1715 "Flags:%x, Packets_flooded:%x, Status: %s ",
1716 rulla->flags, rulla->packets_flooded,
1717 get_status_string(rulla->status));
1718 offset+=sprintf(buf+offset,"->%lx\n",(long)rulla->next);
1719 rulla = rulla->next;
1720 printk("%s",buf);
1721 }
1722 1719
1723#endif
1724} 1720}
1721#else
1722#define dump_arp_table(priv) do { } while (0)
1723#endif
1725 1724
1726/* 1725/*
1727 * Destruction of arp-cache 1726 * Destruction of arp-cache
1728 */ 1727 */
1729static void 1728static void lec_arp_destroy(struct lec_priv *priv)
1730lec_arp_destroy(struct lec_priv *priv)
1731{ 1729{
1732 unsigned long flags; 1730 unsigned long flags;
1733 struct lec_arp_table *entry, *next; 1731 struct hlist_node *node, *next;
1734 int i; 1732 struct lec_arp_table *entry;
1733 int i;
1734
1735 cancel_rearming_delayed_work(&priv->lec_arp_work);
1735 1736
1736 del_timer_sync(&priv->lec_arp_timer); 1737 /*
1737 1738 * Remove all entries
1738 /* 1739 */
1739 * Remove all entries
1740 */
1741 1740
1742 spin_lock_irqsave(&priv->lec_arp_lock, flags); 1741 spin_lock_irqsave(&priv->lec_arp_lock, flags);
1743 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { 1742 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
1744 for(entry = priv->lec_arp_tables[i]; entry != NULL; entry=next) { 1743 hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_tables[i], next) {
1745 next = entry->next; 1744 lec_arp_remove(priv, entry);
1746 lec_arp_remove(priv, entry); 1745 lec_arp_put(entry);
1747 kfree(entry); 1746 }
1748 } 1747 INIT_HLIST_HEAD(&priv->lec_arp_tables[i]);
1749 } 1748 }
1750 entry = priv->lec_arp_empty_ones; 1749
1751 while(entry) { 1750 hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_empty_ones, next) {
1752 next = entry->next; 1751 del_timer_sync(&entry->timer);
1753 del_timer_sync(&entry->timer); 1752 lec_arp_clear_vccs(entry);
1754 lec_arp_clear_vccs(entry); 1753 hlist_del(&entry->next);
1755 kfree(entry); 1754 lec_arp_put(entry);
1756 entry = next; 1755 }
1757 } 1756 INIT_HLIST_HEAD(&priv->lec_arp_empty_ones);
1758 priv->lec_arp_empty_ones = NULL; 1757
1759 entry = priv->lec_no_forward; 1758 hlist_for_each_entry_safe(entry, node, next, &priv->lec_no_forward, next) {
1760 while(entry) { 1759 del_timer_sync(&entry->timer);
1761 next = entry->next; 1760 lec_arp_clear_vccs(entry);
1762 del_timer_sync(&entry->timer); 1761 hlist_del(&entry->next);
1763 lec_arp_clear_vccs(entry); 1762 lec_arp_put(entry);
1764 kfree(entry); 1763 }
1765 entry = next; 1764 INIT_HLIST_HEAD(&priv->lec_no_forward);
1766 } 1765
1767 priv->lec_no_forward = NULL; 1766 hlist_for_each_entry_safe(entry, node, next, &priv->mcast_fwds, next) {
1768 entry = priv->mcast_fwds; 1767 /* No timer, LANEv2 7.1.20 and 2.3.5.3 */
1769 while(entry) { 1768 lec_arp_clear_vccs(entry);
1770 next = entry->next; 1769 hlist_del(&entry->next);
1771 /* No timer, LANEv2 7.1.20 and 2.3.5.3 */ 1770 lec_arp_put(entry);
1772 lec_arp_clear_vccs(entry); 1771 }
1773 kfree(entry); 1772 INIT_HLIST_HEAD(&priv->mcast_fwds);
1774 entry = next; 1773 priv->mcast_vcc = NULL;
1775 }
1776 priv->mcast_fwds = NULL;
1777 priv->mcast_vcc = NULL;
1778 memset(priv->lec_arp_tables, 0,
1779 sizeof(struct lec_arp_table *) * LEC_ARP_TABLE_SIZE);
1780 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); 1774 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
1781} 1775}
1782 1776
1783
1784/* 1777/*
1785 * Find entry by mac_address 1778 * Find entry by mac_address
1786 */ 1779 */
1787static struct lec_arp_table* 1780static struct lec_arp_table *lec_arp_find(struct lec_priv *priv,
1788lec_arp_find(struct lec_priv *priv, 1781 unsigned char *mac_addr)
1789 unsigned char *mac_addr)
1790{ 1782{
1791 unsigned short place; 1783 struct hlist_node *node;
1792 struct lec_arp_table *to_return; 1784 struct hlist_head *head;
1793 1785 struct lec_arp_table *entry;
1794 DPRINTK("LEC_ARP: lec_arp_find :%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n", 1786
1795 mac_addr[0]&0xff, mac_addr[1]&0xff, mac_addr[2]&0xff, 1787 DPRINTK("LEC_ARP: lec_arp_find :%2.2x %2.2x %2.2x %2.2x %2.2x %2.2x\n",
1796 mac_addr[3]&0xff, mac_addr[4]&0xff, mac_addr[5]&0xff); 1788 mac_addr[0] & 0xff, mac_addr[1] & 0xff, mac_addr[2] & 0xff,
1797 place = HASH(mac_addr[ETH_ALEN-1]); 1789 mac_addr[3] & 0xff, mac_addr[4] & 0xff, mac_addr[5] & 0xff);
1798 1790
1799 to_return = priv->lec_arp_tables[place]; 1791 head = &priv->lec_arp_tables[HASH(mac_addr[ETH_ALEN - 1])];
1800 while(to_return) { 1792 hlist_for_each_entry(entry, node, head, next) {
1801 if (!compare_ether_addr(mac_addr, to_return->mac_addr)) { 1793 if (!compare_ether_addr(mac_addr, entry->mac_addr)) {
1802 return to_return; 1794 return entry;
1803 } 1795 }
1804 to_return = to_return->next; 1796 }
1805 } 1797 return NULL;
1806 return NULL;
1807} 1798}
1808 1799
1809static struct lec_arp_table* 1800static struct lec_arp_table *make_entry(struct lec_priv *priv,
1810make_entry(struct lec_priv *priv, unsigned char *mac_addr) 1801 unsigned char *mac_addr)
1811{ 1802{
1812 struct lec_arp_table *to_return; 1803 struct lec_arp_table *to_return;
1813 1804
1814 to_return = kzalloc(sizeof(struct lec_arp_table), GFP_ATOMIC); 1805 to_return = kzalloc(sizeof(struct lec_arp_table), GFP_ATOMIC);
1815 if (!to_return) { 1806 if (!to_return) {
1816 printk("LEC: Arp entry kmalloc failed\n"); 1807 printk("LEC: Arp entry kmalloc failed\n");
1817 return NULL; 1808 return NULL;
1818 } 1809 }
1819 memcpy(to_return->mac_addr, mac_addr, ETH_ALEN); 1810 memcpy(to_return->mac_addr, mac_addr, ETH_ALEN);
1820 init_timer(&to_return->timer); 1811 INIT_HLIST_NODE(&to_return->next);
1821 to_return->timer.function = lec_arp_expire_arp; 1812 init_timer(&to_return->timer);
1822 to_return->timer.data = (unsigned long) to_return; 1813 to_return->timer.function = lec_arp_expire_arp;
1823 to_return->last_used = jiffies; 1814 to_return->timer.data = (unsigned long)to_return;
1824 to_return->priv = priv; 1815 to_return->last_used = jiffies;
1825 skb_queue_head_init(&to_return->tx_wait); 1816 to_return->priv = priv;
1826 return to_return; 1817 skb_queue_head_init(&to_return->tx_wait);
1818 atomic_set(&to_return->usage, 1);
1819 return to_return;
1827} 1820}
1828 1821
1829/* 1822/* Arp sent timer expired */
1830 * 1823static void lec_arp_expire_arp(unsigned long data)
1831 * Arp sent timer expired
1832 *
1833 */
1834static void
1835lec_arp_expire_arp(unsigned long data)
1836{ 1824{
1837 struct lec_arp_table *entry; 1825 struct lec_arp_table *entry;
1838 1826
1839 entry = (struct lec_arp_table *)data; 1827 entry = (struct lec_arp_table *)data;
1840 1828
1841 DPRINTK("lec_arp_expire_arp\n"); 1829 DPRINTK("lec_arp_expire_arp\n");
1842 if (entry->status == ESI_ARP_PENDING) { 1830 if (entry->status == ESI_ARP_PENDING) {
1843 if (entry->no_tries <= entry->priv->max_retry_count) { 1831 if (entry->no_tries <= entry->priv->max_retry_count) {
1844 if (entry->is_rdesc) 1832 if (entry->is_rdesc)
1845 send_to_lecd(entry->priv, l_rdesc_arp_xmt, entry->mac_addr, NULL, NULL); 1833 send_to_lecd(entry->priv, l_rdesc_arp_xmt,
1846 else 1834 entry->mac_addr, NULL, NULL);
1847 send_to_lecd(entry->priv, l_arp_xmt, entry->mac_addr, NULL, NULL); 1835 else
1848 entry->no_tries++; 1836 send_to_lecd(entry->priv, l_arp_xmt,
1849 } 1837 entry->mac_addr, NULL, NULL);
1850 mod_timer(&entry->timer, jiffies + (1*HZ)); 1838 entry->no_tries++;
1851 } 1839 }
1840 mod_timer(&entry->timer, jiffies + (1 * HZ));
1841 }
1852} 1842}
1853 1843
1854/* 1844/* Unknown/unused vcc expire, remove associated entry */
1855 * 1845static void lec_arp_expire_vcc(unsigned long data)
1856 * Unknown/unused vcc expire, remove associated entry
1857 *
1858 */
1859static void
1860lec_arp_expire_vcc(unsigned long data)
1861{ 1846{
1862 unsigned long flags; 1847 unsigned long flags;
1863 struct lec_arp_table *to_remove = (struct lec_arp_table*)data; 1848 struct lec_arp_table *to_remove = (struct lec_arp_table *)data;
1864 struct lec_priv *priv = (struct lec_priv *)to_remove->priv; 1849 struct lec_priv *priv = (struct lec_priv *)to_remove->priv;
1865 struct lec_arp_table *entry = NULL;
1866 1850
1867 del_timer(&to_remove->timer); 1851 del_timer(&to_remove->timer);
1868 1852
1869 DPRINTK("LEC_ARP %p %p: lec_arp_expire_vcc vpi:%d vci:%d\n", 1853 DPRINTK("LEC_ARP %p %p: lec_arp_expire_vcc vpi:%d vci:%d\n",
1870 to_remove, priv, 1854 to_remove, priv,
1871 to_remove->vcc?to_remove->recv_vcc->vpi:0, 1855 to_remove->vcc ? to_remove->recv_vcc->vpi : 0,
1872 to_remove->vcc?to_remove->recv_vcc->vci:0); 1856 to_remove->vcc ? to_remove->recv_vcc->vci : 0);
1873 DPRINTK("eo:%p nf:%p\n",priv->lec_arp_empty_ones,priv->lec_no_forward);
1874 1857
1875 spin_lock_irqsave(&priv->lec_arp_lock, flags); 1858 spin_lock_irqsave(&priv->lec_arp_lock, flags);
1876 if (to_remove == priv->lec_arp_empty_ones) 1859 hlist_del(&to_remove->next);
1877 priv->lec_arp_empty_ones = to_remove->next;
1878 else {
1879 entry = priv->lec_arp_empty_ones;
1880 while (entry && entry->next != to_remove)
1881 entry = entry->next;
1882 if (entry)
1883 entry->next = to_remove->next;
1884 }
1885 if (!entry) {
1886 if (to_remove == priv->lec_no_forward) {
1887 priv->lec_no_forward = to_remove->next;
1888 } else {
1889 entry = priv->lec_no_forward;
1890 while (entry && entry->next != to_remove)
1891 entry = entry->next;
1892 if (entry)
1893 entry->next = to_remove->next;
1894 }
1895 }
1896 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); 1860 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
1897 1861
1898 lec_arp_clear_vccs(to_remove); 1862 lec_arp_clear_vccs(to_remove);
1899 kfree(to_remove); 1863 lec_arp_put(to_remove);
1900} 1864}
1901 1865
1902/* 1866/*
@@ -1915,158 +1879,171 @@ lec_arp_expire_vcc(unsigned long data)
1915 * to ESI_FORWARD_DIRECT. This causes the flush period to end 1879 * to ESI_FORWARD_DIRECT. This causes the flush period to end
1916 * regardless of the progress of the flush protocol. 1880 * regardless of the progress of the flush protocol.
1917 */ 1881 */
1918static void 1882static void lec_arp_check_expire(void *data)
1919lec_arp_check_expire(unsigned long data)
1920{ 1883{
1921 unsigned long flags; 1884 unsigned long flags;
1922 struct lec_priv *priv = (struct lec_priv *)data; 1885 struct lec_priv *priv = data;
1923 struct lec_arp_table *entry, *next; 1886 struct hlist_node *node, *next;
1924 unsigned long now; 1887 struct lec_arp_table *entry;
1925 unsigned long time_to_check; 1888 unsigned long now;
1926 int i; 1889 unsigned long time_to_check;
1927 1890 int i;
1928 DPRINTK("lec_arp_check_expire %p\n",priv); 1891
1929 DPRINTK("expire: eo:%p nf:%p\n",priv->lec_arp_empty_ones, 1892 DPRINTK("lec_arp_check_expire %p\n", priv);
1930 priv->lec_no_forward);
1931 now = jiffies; 1893 now = jiffies;
1894restart:
1932 spin_lock_irqsave(&priv->lec_arp_lock, flags); 1895 spin_lock_irqsave(&priv->lec_arp_lock, flags);
1933 for(i = 0; i < LEC_ARP_TABLE_SIZE; i++) { 1896 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
1934 for(entry = priv->lec_arp_tables[i]; entry != NULL; ) { 1897 hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_tables[i], next) {
1935 if ((entry->flags) & LEC_REMOTE_FLAG && 1898 if ((entry->flags) & LEC_REMOTE_FLAG &&
1936 priv->topology_change) 1899 priv->topology_change)
1937 time_to_check = priv->forward_delay_time; 1900 time_to_check = priv->forward_delay_time;
1938 else 1901 else
1939 time_to_check = priv->aging_time; 1902 time_to_check = priv->aging_time;
1940 1903
1941 DPRINTK("About to expire: %lx - %lx > %lx\n", 1904 DPRINTK("About to expire: %lx - %lx > %lx\n",
1942 now,entry->last_used, time_to_check); 1905 now, entry->last_used, time_to_check);
1943 if( time_after(now, entry->last_used+ 1906 if (time_after(now, entry->last_used + time_to_check)
1944 time_to_check) && 1907 && !(entry->flags & LEC_PERMANENT_FLAG)
1945 !(entry->flags & LEC_PERMANENT_FLAG) && 1908 && !(entry->mac_addr[0] & 0x01)) { /* LANE2: 7.1.20 */
1946 !(entry->mac_addr[0] & 0x01) ) { /* LANE2: 7.1.20 */
1947 /* Remove entry */ 1909 /* Remove entry */
1948 DPRINTK("LEC:Entry timed out\n"); 1910 DPRINTK("LEC:Entry timed out\n");
1949 next = entry->next;
1950 lec_arp_remove(priv, entry); 1911 lec_arp_remove(priv, entry);
1951 kfree(entry); 1912 lec_arp_put(entry);
1952 entry = next;
1953 } else { 1913 } else {
1954 /* Something else */ 1914 /* Something else */
1955 if ((entry->status == ESI_VC_PENDING || 1915 if ((entry->status == ESI_VC_PENDING ||
1956 entry->status == ESI_ARP_PENDING) 1916 entry->status == ESI_ARP_PENDING)
1957 && time_after_eq(now, 1917 && time_after_eq(now,
1958 entry->timestamp + 1918 entry->timestamp +
1959 priv->max_unknown_frame_time)) { 1919 priv->
1920 max_unknown_frame_time)) {
1960 entry->timestamp = jiffies; 1921 entry->timestamp = jiffies;
1961 entry->packets_flooded = 0; 1922 entry->packets_flooded = 0;
1962 if (entry->status == ESI_VC_PENDING) 1923 if (entry->status == ESI_VC_PENDING)
1963 send_to_lecd(priv, l_svc_setup, entry->mac_addr, entry->atm_addr, NULL); 1924 send_to_lecd(priv, l_svc_setup,
1925 entry->mac_addr,
1926 entry->atm_addr,
1927 NULL);
1964 } 1928 }
1965 if (entry->status == ESI_FLUSH_PENDING 1929 if (entry->status == ESI_FLUSH_PENDING
1966 && 1930 &&
1967 time_after_eq(now, entry->timestamp+ 1931 time_after_eq(now, entry->timestamp +
1968 priv->path_switching_delay)) { 1932 priv->path_switching_delay)) {
1969 struct sk_buff *skb; 1933 struct sk_buff *skb;
1934 struct atm_vcc *vcc = entry->vcc;
1970 1935
1936 lec_arp_hold(entry);
1937 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
1971 while ((skb = skb_dequeue(&entry->tx_wait)) != NULL) 1938 while ((skb = skb_dequeue(&entry->tx_wait)) != NULL)
1972 lec_send(entry->vcc, skb, entry->priv); 1939 lec_send(vcc, skb, entry->priv);
1973 entry->last_used = jiffies; 1940 entry->last_used = jiffies;
1974 entry->status = 1941 entry->status = ESI_FORWARD_DIRECT;
1975 ESI_FORWARD_DIRECT; 1942 lec_arp_put(entry);
1943 goto restart;
1976 } 1944 }
1977 entry = entry->next;
1978 } 1945 }
1979 } 1946 }
1980 } 1947 }
1981 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); 1948 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
1982 1949
1983 mod_timer(&priv->lec_arp_timer, jiffies + LEC_ARP_REFRESH_INTERVAL); 1950 schedule_delayed_work(&priv->lec_arp_work, LEC_ARP_REFRESH_INTERVAL);
1984} 1951}
1952
1985/* 1953/*
1986 * Try to find vcc where mac_address is attached. 1954 * Try to find vcc where mac_address is attached.
1987 * 1955 *
1988 */ 1956 */
1989static struct atm_vcc* 1957static struct atm_vcc *lec_arp_resolve(struct lec_priv *priv,
1990lec_arp_resolve(struct lec_priv *priv, unsigned char *mac_to_find, 1958 unsigned char *mac_to_find, int is_rdesc,
1991 int is_rdesc, struct lec_arp_table **ret_entry) 1959 struct lec_arp_table **ret_entry)
1992{ 1960{
1993 unsigned long flags; 1961 unsigned long flags;
1994 struct lec_arp_table *entry; 1962 struct lec_arp_table *entry;
1995 struct atm_vcc *found; 1963 struct atm_vcc *found;
1996 1964
1997 if (mac_to_find[0] & 0x01) { 1965 if (mac_to_find[0] & 0x01) {
1998 switch (priv->lane_version) { 1966 switch (priv->lane_version) {
1999 case 1: 1967 case 1:
2000 return priv->mcast_vcc; 1968 return priv->mcast_vcc;
2001 break; 1969 break;
2002 case 2: /* LANE2 wants arp for multicast addresses */ 1970 case 2: /* LANE2 wants arp for multicast addresses */
2003 if (!compare_ether_addr(mac_to_find, bus_mac)) 1971 if (!compare_ether_addr(mac_to_find, bus_mac))
2004 return priv->mcast_vcc; 1972 return priv->mcast_vcc;
2005 break; 1973 break;
2006 default: 1974 default:
2007 break; 1975 break;
2008 } 1976 }
2009 } 1977 }
2010 1978
2011 spin_lock_irqsave(&priv->lec_arp_lock, flags); 1979 spin_lock_irqsave(&priv->lec_arp_lock, flags);
2012 entry = lec_arp_find(priv, mac_to_find); 1980 entry = lec_arp_find(priv, mac_to_find);
2013 1981
2014 if (entry) { 1982 if (entry) {
2015 if (entry->status == ESI_FORWARD_DIRECT) { 1983 if (entry->status == ESI_FORWARD_DIRECT) {
2016 /* Connection Ok */ 1984 /* Connection Ok */
2017 entry->last_used = jiffies; 1985 entry->last_used = jiffies;
2018 *ret_entry = entry; 1986 lec_arp_hold(entry);
2019 found = entry->vcc; 1987 *ret_entry = entry;
1988 found = entry->vcc;
2020 goto out; 1989 goto out;
2021 } 1990 }
2022 /* If the LE_ARP cache entry is still pending, reset count to 0 1991 /*
1992 * If the LE_ARP cache entry is still pending, reset count to 0
2023 * so another LE_ARP request can be made for this frame. 1993 * so another LE_ARP request can be made for this frame.
2024 */ 1994 */
2025 if (entry->status == ESI_ARP_PENDING) { 1995 if (entry->status == ESI_ARP_PENDING) {
2026 entry->no_tries = 0; 1996 entry->no_tries = 0;
2027 } 1997 }
2028 /* Data direct VC not yet set up, check to see if the unknown 1998 /*
2029 frame count is greater than the limit. If the limit has 1999 * Data direct VC not yet set up, check to see if the unknown
2030 not been reached, allow the caller to send packet to 2000 * frame count is greater than the limit. If the limit has
2031 BUS. */ 2001 * not been reached, allow the caller to send packet to
2032 if (entry->status != ESI_FLUSH_PENDING && 2002 * BUS.
2033 entry->packets_flooded<priv->maximum_unknown_frame_count) { 2003 */
2034 entry->packets_flooded++; 2004 if (entry->status != ESI_FLUSH_PENDING &&
2035 DPRINTK("LEC_ARP: Flooding..\n"); 2005 entry->packets_flooded <
2036 found = priv->mcast_vcc; 2006 priv->maximum_unknown_frame_count) {
2007 entry->packets_flooded++;
2008 DPRINTK("LEC_ARP: Flooding..\n");
2009 found = priv->mcast_vcc;
2037 goto out; 2010 goto out;
2038 } 2011 }
2039 /* We got here because entry->status == ESI_FLUSH_PENDING 2012 /*
2013 * We got here because entry->status == ESI_FLUSH_PENDING
2040 * or BUS flood limit was reached for an entry which is 2014 * or BUS flood limit was reached for an entry which is
2041 * in ESI_ARP_PENDING or ESI_VC_PENDING state. 2015 * in ESI_ARP_PENDING or ESI_VC_PENDING state.
2042 */ 2016 */
2043 *ret_entry = entry; 2017 lec_arp_hold(entry);
2044 DPRINTK("lec: entry->status %d entry->vcc %p\n", entry->status, entry->vcc); 2018 *ret_entry = entry;
2045 found = NULL; 2019 DPRINTK("lec: entry->status %d entry->vcc %p\n", entry->status,
2046 } else { 2020 entry->vcc);
2047 /* No matching entry was found */ 2021 found = NULL;
2048 entry = make_entry(priv, mac_to_find); 2022 } else {
2049 DPRINTK("LEC_ARP: Making entry\n"); 2023 /* No matching entry was found */
2050 if (!entry) { 2024 entry = make_entry(priv, mac_to_find);
2051 found = priv->mcast_vcc; 2025 DPRINTK("LEC_ARP: Making entry\n");
2026 if (!entry) {
2027 found = priv->mcast_vcc;
2052 goto out; 2028 goto out;
2053 } 2029 }
2054 lec_arp_add(priv, entry); 2030 lec_arp_add(priv, entry);
2055 /* We want arp-request(s) to be sent */ 2031 /* We want arp-request(s) to be sent */
2056 entry->packets_flooded =1; 2032 entry->packets_flooded = 1;
2057 entry->status = ESI_ARP_PENDING; 2033 entry->status = ESI_ARP_PENDING;
2058 entry->no_tries = 1; 2034 entry->no_tries = 1;
2059 entry->last_used = entry->timestamp = jiffies; 2035 entry->last_used = entry->timestamp = jiffies;
2060 entry->is_rdesc = is_rdesc; 2036 entry->is_rdesc = is_rdesc;
2061 if (entry->is_rdesc) 2037 if (entry->is_rdesc)
2062 send_to_lecd(priv, l_rdesc_arp_xmt, mac_to_find, NULL, NULL); 2038 send_to_lecd(priv, l_rdesc_arp_xmt, mac_to_find, NULL,
2063 else 2039 NULL);
2064 send_to_lecd(priv, l_arp_xmt, mac_to_find, NULL, NULL); 2040 else
2065 entry->timer.expires = jiffies + (1*HZ); 2041 send_to_lecd(priv, l_arp_xmt, mac_to_find, NULL, NULL);
2066 entry->timer.function = lec_arp_expire_arp; 2042 entry->timer.expires = jiffies + (1 * HZ);
2067 add_timer(&entry->timer); 2043 entry->timer.function = lec_arp_expire_arp;
2068 found = priv->mcast_vcc; 2044 add_timer(&entry->timer);
2069 } 2045 found = priv->mcast_vcc;
2046 }
2070 2047
2071out: 2048out:
2072 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); 2049 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
@@ -2074,30 +2051,30 @@ out:
2074} 2051}
2075 2052
2076static int 2053static int
2077lec_addr_delete(struct lec_priv *priv, unsigned char *atm_addr, 2054lec_addr_delete(struct lec_priv *priv, unsigned char *atm_addr,
2078 unsigned long permanent) 2055 unsigned long permanent)
2079{ 2056{
2080 unsigned long flags; 2057 unsigned long flags;
2081 struct lec_arp_table *entry, *next; 2058 struct hlist_node *node, *next;
2082 int i; 2059 struct lec_arp_table *entry;
2060 int i;
2083 2061
2084 DPRINTK("lec_addr_delete\n"); 2062 DPRINTK("lec_addr_delete\n");
2085 spin_lock_irqsave(&priv->lec_arp_lock, flags); 2063 spin_lock_irqsave(&priv->lec_arp_lock, flags);
2086 for(i = 0; i < LEC_ARP_TABLE_SIZE; i++) { 2064 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
2087 for(entry = priv->lec_arp_tables[i]; entry != NULL; entry = next) { 2065 hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_tables[i], next) {
2088 next = entry->next; 2066 if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN)
2089 if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN) 2067 && (permanent ||
2090 && (permanent || 2068 !(entry->flags & LEC_PERMANENT_FLAG))) {
2091 !(entry->flags & LEC_PERMANENT_FLAG))) {
2092 lec_arp_remove(priv, entry); 2069 lec_arp_remove(priv, entry);
2093 kfree(entry); 2070 lec_arp_put(entry);
2094 } 2071 }
2095 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); 2072 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
2096 return 0; 2073 return 0;
2097 } 2074 }
2098 } 2075 }
2099 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); 2076 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
2100 return -1; 2077 return -1;
2101} 2078}
2102 2079
2103/* 2080/*
@@ -2105,109 +2082,98 @@ lec_addr_delete(struct lec_priv *priv, unsigned char *atm_addr,
2105 */ 2082 */
2106static void 2083static void
2107lec_arp_update(struct lec_priv *priv, unsigned char *mac_addr, 2084lec_arp_update(struct lec_priv *priv, unsigned char *mac_addr,
2108 unsigned char *atm_addr, unsigned long remoteflag, 2085 unsigned char *atm_addr, unsigned long remoteflag,
2109 unsigned int targetless_le_arp) 2086 unsigned int targetless_le_arp)
2110{ 2087{
2111 unsigned long flags; 2088 unsigned long flags;
2112 struct lec_arp_table *entry, *tmp; 2089 struct hlist_node *node, *next;
2113 int i; 2090 struct lec_arp_table *entry, *tmp;
2091 int i;
2114 2092
2115 DPRINTK("lec:%s", (targetless_le_arp) ? "targetless ": " "); 2093 DPRINTK("lec:%s", (targetless_le_arp) ? "targetless " : " ");
2116 DPRINTK("lec_arp_update mac:%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n", 2094 DPRINTK("lec_arp_update mac:%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n",
2117 mac_addr[0],mac_addr[1],mac_addr[2],mac_addr[3], 2095 mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3],
2118 mac_addr[4],mac_addr[5]); 2096 mac_addr[4], mac_addr[5]);
2119 2097
2120 spin_lock_irqsave(&priv->lec_arp_lock, flags); 2098 spin_lock_irqsave(&priv->lec_arp_lock, flags);
2121 entry = lec_arp_find(priv, mac_addr); 2099 entry = lec_arp_find(priv, mac_addr);
2122 if (entry == NULL && targetless_le_arp) 2100 if (entry == NULL && targetless_le_arp)
2123 goto out; /* LANE2: ignore targetless LE_ARPs for which 2101 goto out; /*
2124 * we have no entry in the cache. 7.1.30 2102 * LANE2: ignore targetless LE_ARPs for which
2125 */ 2103 * we have no entry in the cache. 7.1.30
2126 if (priv->lec_arp_empty_ones) { 2104 */
2127 entry = priv->lec_arp_empty_ones; 2105 if (!hlist_empty(&priv->lec_arp_empty_ones)) {
2128 if (!memcmp(entry->atm_addr, atm_addr, ATM_ESA_LEN)) { 2106 hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_empty_ones, next) {
2129 priv->lec_arp_empty_ones = entry->next; 2107 if (memcmp(entry->atm_addr, atm_addr, ATM_ESA_LEN) == 0) {
2130 } else { 2108 hlist_del(&entry->next);
2131 while(entry->next && memcmp(entry->next->atm_addr, 2109 del_timer(&entry->timer);
2132 atm_addr, ATM_ESA_LEN)) 2110 tmp = lec_arp_find(priv, mac_addr);
2133 entry = entry->next; 2111 if (tmp) {
2134 if (entry->next) { 2112 del_timer(&tmp->timer);
2135 tmp = entry; 2113 tmp->status = ESI_FORWARD_DIRECT;
2136 entry = entry->next; 2114 memcpy(tmp->atm_addr, atm_addr, ATM_ESA_LEN);
2137 tmp->next = entry->next; 2115 tmp->vcc = entry->vcc;
2138 } else 2116 tmp->old_push = entry->old_push;
2139 entry = NULL; 2117 tmp->last_used = jiffies;
2140 2118 del_timer(&entry->timer);
2141 } 2119 lec_arp_put(entry);
2142 if (entry) { 2120 entry = tmp;
2143 del_timer(&entry->timer); 2121 } else {
2144 tmp = lec_arp_find(priv, mac_addr); 2122 entry->status = ESI_FORWARD_DIRECT;
2145 if (tmp) { 2123 memcpy(entry->mac_addr, mac_addr, ETH_ALEN);
2146 del_timer(&tmp->timer); 2124 entry->last_used = jiffies;
2147 tmp->status = ESI_FORWARD_DIRECT; 2125 lec_arp_add(priv, entry);
2148 memcpy(tmp->atm_addr, atm_addr, ATM_ESA_LEN); 2126 }
2149 tmp->vcc = entry->vcc; 2127 if (remoteflag)
2150 tmp->old_push = entry->old_push; 2128 entry->flags |= LEC_REMOTE_FLAG;
2151 tmp->last_used = jiffies; 2129 else
2152 del_timer(&entry->timer); 2130 entry->flags &= ~LEC_REMOTE_FLAG;
2153 kfree(entry); 2131 DPRINTK("After update\n");
2154 entry=tmp; 2132 dump_arp_table(priv);
2155 } else { 2133 goto out;
2156 entry->status = ESI_FORWARD_DIRECT; 2134 }
2157 memcpy(entry->mac_addr, mac_addr, ETH_ALEN); 2135 }
2158 entry->last_used = jiffies; 2136 }
2159 lec_arp_add(priv, entry); 2137
2160 } 2138 entry = lec_arp_find(priv, mac_addr);
2161 if (remoteflag) 2139 if (!entry) {
2162 entry->flags|=LEC_REMOTE_FLAG; 2140 entry = make_entry(priv, mac_addr);
2163 else 2141 if (!entry)
2164 entry->flags&=~LEC_REMOTE_FLAG;
2165 DPRINTK("After update\n");
2166 dump_arp_table(priv);
2167 goto out;
2168 }
2169 }
2170 entry = lec_arp_find(priv, mac_addr);
2171 if (!entry) {
2172 entry = make_entry(priv, mac_addr);
2173 if (!entry)
2174 goto out; 2142 goto out;
2175 entry->status = ESI_UNKNOWN; 2143 entry->status = ESI_UNKNOWN;
2176 lec_arp_add(priv, entry); 2144 lec_arp_add(priv, entry);
2177 /* Temporary, changes before end of function */ 2145 /* Temporary, changes before end of function */
2178 } 2146 }
2179 memcpy(entry->atm_addr, atm_addr, ATM_ESA_LEN); 2147 memcpy(entry->atm_addr, atm_addr, ATM_ESA_LEN);
2180 del_timer(&entry->timer); 2148 del_timer(&entry->timer);
2181 for(i = 0; i < LEC_ARP_TABLE_SIZE; i++) { 2149 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
2182 for(tmp = priv->lec_arp_tables[i]; tmp; tmp=tmp->next) { 2150 hlist_for_each_entry(tmp, node, &priv->lec_arp_tables[i], next) {
2183 if (entry != tmp && 2151 if (entry != tmp &&
2184 !memcmp(tmp->atm_addr, atm_addr, 2152 !memcmp(tmp->atm_addr, atm_addr, ATM_ESA_LEN)) {
2185 ATM_ESA_LEN)) { 2153 /* Vcc to this host exists */
2186 /* Vcc to this host exists */ 2154 if (tmp->status > ESI_VC_PENDING) {
2187 if (tmp->status > ESI_VC_PENDING) { 2155 /*
2188 /* 2156 * ESI_FLUSH_PENDING,
2189 * ESI_FLUSH_PENDING, 2157 * ESI_FORWARD_DIRECT
2190 * ESI_FORWARD_DIRECT 2158 */
2191 */ 2159 entry->vcc = tmp->vcc;
2192 entry->vcc = tmp->vcc; 2160 entry->old_push = tmp->old_push;
2193 entry->old_push=tmp->old_push; 2161 }
2194 } 2162 entry->status = tmp->status;
2195 entry->status=tmp->status; 2163 break;
2196 break; 2164 }
2197 } 2165 }
2198 } 2166 }
2199 } 2167 if (remoteflag)
2200 if (remoteflag) 2168 entry->flags |= LEC_REMOTE_FLAG;
2201 entry->flags|=LEC_REMOTE_FLAG; 2169 else
2202 else 2170 entry->flags &= ~LEC_REMOTE_FLAG;
2203 entry->flags&=~LEC_REMOTE_FLAG; 2171 if (entry->status == ESI_ARP_PENDING || entry->status == ESI_UNKNOWN) {
2204 if (entry->status == ESI_ARP_PENDING || 2172 entry->status = ESI_VC_PENDING;
2205 entry->status == ESI_UNKNOWN) { 2173 send_to_lecd(priv, l_svc_setup, entry->mac_addr, atm_addr, NULL);
2206 entry->status = ESI_VC_PENDING; 2174 }
2207 send_to_lecd(priv, l_svc_setup, entry->mac_addr, atm_addr, NULL); 2175 DPRINTK("After update2\n");
2208 } 2176 dump_arp_table(priv);
2209 DPRINTK("After update2\n");
2210 dump_arp_table(priv);
2211out: 2177out:
2212 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); 2178 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
2213} 2179}
@@ -2217,299 +2183,299 @@ out:
2217 */ 2183 */
2218static void 2184static void
2219lec_vcc_added(struct lec_priv *priv, struct atmlec_ioc *ioc_data, 2185lec_vcc_added(struct lec_priv *priv, struct atmlec_ioc *ioc_data,
2220 struct atm_vcc *vcc, 2186 struct atm_vcc *vcc,
2221 void (*old_push)(struct atm_vcc *vcc, struct sk_buff *skb)) 2187 void (*old_push) (struct atm_vcc *vcc, struct sk_buff *skb))
2222{ 2188{
2223 unsigned long flags; 2189 unsigned long flags;
2224 struct lec_arp_table *entry; 2190 struct hlist_node *node;
2225 int i, found_entry=0; 2191 struct lec_arp_table *entry;
2192 int i, found_entry = 0;
2226 2193
2227 spin_lock_irqsave(&priv->lec_arp_lock, flags); 2194 spin_lock_irqsave(&priv->lec_arp_lock, flags);
2228 if (ioc_data->receive == 2) { 2195 if (ioc_data->receive == 2) {
2229 /* Vcc for Multicast Forward. No timer, LANEv2 7.1.20 and 2.3.5.3 */ 2196 /* Vcc for Multicast Forward. No timer, LANEv2 7.1.20 and 2.3.5.3 */
2230 2197
2231 DPRINTK("LEC_ARP: Attaching mcast forward\n"); 2198 DPRINTK("LEC_ARP: Attaching mcast forward\n");
2232#if 0 2199#if 0
2233 entry = lec_arp_find(priv, bus_mac); 2200 entry = lec_arp_find(priv, bus_mac);
2234 if (!entry) { 2201 if (!entry) {
2235 printk("LEC_ARP: Multicast entry not found!\n"); 2202 printk("LEC_ARP: Multicast entry not found!\n");
2236 goto out; 2203 goto out;
2237 } 2204 }
2238 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); 2205 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
2239 entry->recv_vcc = vcc; 2206 entry->recv_vcc = vcc;
2240 entry->old_recv_push = old_push; 2207 entry->old_recv_push = old_push;
2241#endif 2208#endif
2242 entry = make_entry(priv, bus_mac); 2209 entry = make_entry(priv, bus_mac);
2243 if (entry == NULL) 2210 if (entry == NULL)
2244 goto out; 2211 goto out;
2245 del_timer(&entry->timer); 2212 del_timer(&entry->timer);
2246 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); 2213 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
2247 entry->recv_vcc = vcc; 2214 entry->recv_vcc = vcc;
2248 entry->old_recv_push = old_push; 2215 entry->old_recv_push = old_push;
2249 entry->next = priv->mcast_fwds; 2216 hlist_add_head(&entry->next, &priv->mcast_fwds);
2250 priv->mcast_fwds = entry; 2217 goto out;
2251 goto out; 2218 } else if (ioc_data->receive == 1) {
2252 } else if (ioc_data->receive == 1) { 2219 /*
2253 /* Vcc which we don't want to make default vcc, attach it 2220 * Vcc which we don't want to make default vcc,
2254 anyway. */ 2221 * attach it anyway.
2255 DPRINTK("LEC_ARP:Attaching data direct, not default :%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n", 2222 */
2256 ioc_data->atm_addr[0],ioc_data->atm_addr[1], 2223 DPRINTK
2257 ioc_data->atm_addr[2],ioc_data->atm_addr[3], 2224 ("LEC_ARP:Attaching data direct, not default: "
2258 ioc_data->atm_addr[4],ioc_data->atm_addr[5], 2225 "%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n",
2259 ioc_data->atm_addr[6],ioc_data->atm_addr[7], 2226 ioc_data->atm_addr[0], ioc_data->atm_addr[1],
2260 ioc_data->atm_addr[8],ioc_data->atm_addr[9], 2227 ioc_data->atm_addr[2], ioc_data->atm_addr[3],
2261 ioc_data->atm_addr[10],ioc_data->atm_addr[11], 2228 ioc_data->atm_addr[4], ioc_data->atm_addr[5],
2262 ioc_data->atm_addr[12],ioc_data->atm_addr[13], 2229 ioc_data->atm_addr[6], ioc_data->atm_addr[7],
2263 ioc_data->atm_addr[14],ioc_data->atm_addr[15], 2230 ioc_data->atm_addr[8], ioc_data->atm_addr[9],
2264 ioc_data->atm_addr[16],ioc_data->atm_addr[17], 2231 ioc_data->atm_addr[10], ioc_data->atm_addr[11],
2265 ioc_data->atm_addr[18],ioc_data->atm_addr[19]); 2232 ioc_data->atm_addr[12], ioc_data->atm_addr[13],
2266 entry = make_entry(priv, bus_mac); 2233 ioc_data->atm_addr[14], ioc_data->atm_addr[15],
2267 if (entry == NULL) 2234 ioc_data->atm_addr[16], ioc_data->atm_addr[17],
2235 ioc_data->atm_addr[18], ioc_data->atm_addr[19]);
2236 entry = make_entry(priv, bus_mac);
2237 if (entry == NULL)
2268 goto out; 2238 goto out;
2269 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); 2239 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
2270 memset(entry->mac_addr, 0, ETH_ALEN); 2240 memset(entry->mac_addr, 0, ETH_ALEN);
2271 entry->recv_vcc = vcc; 2241 entry->recv_vcc = vcc;
2272 entry->old_recv_push = old_push; 2242 entry->old_recv_push = old_push;
2273 entry->status = ESI_UNKNOWN; 2243 entry->status = ESI_UNKNOWN;
2274 entry->timer.expires = jiffies + priv->vcc_timeout_period; 2244 entry->timer.expires = jiffies + priv->vcc_timeout_period;
2275 entry->timer.function = lec_arp_expire_vcc; 2245 entry->timer.function = lec_arp_expire_vcc;
2276 add_timer(&entry->timer); 2246 hlist_add_head(&entry->next, &priv->lec_no_forward);
2277 entry->next = priv->lec_no_forward; 2247 add_timer(&entry->timer);
2278 priv->lec_no_forward = entry;
2279 dump_arp_table(priv); 2248 dump_arp_table(priv);
2280 goto out; 2249 goto out;
2281 } 2250 }
2282 DPRINTK("LEC_ARP:Attaching data direct, default:%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n", 2251 DPRINTK
2283 ioc_data->atm_addr[0],ioc_data->atm_addr[1], 2252 ("LEC_ARP:Attaching data direct, default: "
2284 ioc_data->atm_addr[2],ioc_data->atm_addr[3], 2253 "%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n",
2285 ioc_data->atm_addr[4],ioc_data->atm_addr[5], 2254 ioc_data->atm_addr[0], ioc_data->atm_addr[1],
2286 ioc_data->atm_addr[6],ioc_data->atm_addr[7], 2255 ioc_data->atm_addr[2], ioc_data->atm_addr[3],
2287 ioc_data->atm_addr[8],ioc_data->atm_addr[9], 2256 ioc_data->atm_addr[4], ioc_data->atm_addr[5],
2288 ioc_data->atm_addr[10],ioc_data->atm_addr[11], 2257 ioc_data->atm_addr[6], ioc_data->atm_addr[7],
2289 ioc_data->atm_addr[12],ioc_data->atm_addr[13], 2258 ioc_data->atm_addr[8], ioc_data->atm_addr[9],
2290 ioc_data->atm_addr[14],ioc_data->atm_addr[15], 2259 ioc_data->atm_addr[10], ioc_data->atm_addr[11],
2291 ioc_data->atm_addr[16],ioc_data->atm_addr[17], 2260 ioc_data->atm_addr[12], ioc_data->atm_addr[13],
2292 ioc_data->atm_addr[18],ioc_data->atm_addr[19]); 2261 ioc_data->atm_addr[14], ioc_data->atm_addr[15],
2293 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { 2262 ioc_data->atm_addr[16], ioc_data->atm_addr[17],
2294 for (entry = priv->lec_arp_tables[i]; entry; entry=entry->next) { 2263 ioc_data->atm_addr[18], ioc_data->atm_addr[19]);
2295 if (memcmp(ioc_data->atm_addr, entry->atm_addr, 2264 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
2296 ATM_ESA_LEN)==0) { 2265 hlist_for_each_entry(entry, node, &priv->lec_arp_tables[i], next) {
2297 DPRINTK("LEC_ARP: Attaching data direct\n"); 2266 if (memcmp
2298 DPRINTK("Currently -> Vcc: %d, Rvcc:%d\n", 2267 (ioc_data->atm_addr, entry->atm_addr,
2299 entry->vcc?entry->vcc->vci:0, 2268 ATM_ESA_LEN) == 0) {
2300 entry->recv_vcc?entry->recv_vcc->vci:0); 2269 DPRINTK("LEC_ARP: Attaching data direct\n");
2301 found_entry=1; 2270 DPRINTK("Currently -> Vcc: %d, Rvcc:%d\n",
2302 del_timer(&entry->timer); 2271 entry->vcc ? entry->vcc->vci : 0,
2303 entry->vcc = vcc; 2272 entry->recv_vcc ? entry->recv_vcc->
2304 entry->old_push = old_push; 2273 vci : 0);
2305 if (entry->status == ESI_VC_PENDING) { 2274 found_entry = 1;
2306 if(priv->maximum_unknown_frame_count 2275 del_timer(&entry->timer);
2307 ==0) 2276 entry->vcc = vcc;
2308 entry->status = 2277 entry->old_push = old_push;
2309 ESI_FORWARD_DIRECT; 2278 if (entry->status == ESI_VC_PENDING) {
2310 else { 2279 if (priv->maximum_unknown_frame_count
2311 entry->timestamp = jiffies; 2280 == 0)
2312 entry->status = 2281 entry->status =
2313 ESI_FLUSH_PENDING; 2282 ESI_FORWARD_DIRECT;
2283 else {
2284 entry->timestamp = jiffies;
2285 entry->status =
2286 ESI_FLUSH_PENDING;
2314#if 0 2287#if 0
2315 send_to_lecd(priv,l_flush_xmt, 2288 send_to_lecd(priv, l_flush_xmt,
2316 NULL, 2289 NULL,
2317 entry->atm_addr, 2290 entry->atm_addr,
2318 NULL); 2291 NULL);
2319#endif 2292#endif
2320 } 2293 }
2321 } else { 2294 } else {
2322 /* They were forming a connection 2295 /*
2323 to us, and we to them. Our 2296 * They were forming a connection
2324 ATM address is numerically lower 2297 * to us, and we to them. Our
2325 than theirs, so we make connection 2298 * ATM address is numerically lower
2326 we formed into default VCC (8.1.11). 2299 * than theirs, so we make connection
2327 Connection they made gets torn 2300 * we formed into default VCC (8.1.11).
2328 down. This might confuse some 2301 * Connection they made gets torn
2329 clients. Can be changed if 2302 * down. This might confuse some
2330 someone reports trouble... */ 2303 * clients. Can be changed if
2331 ; 2304 * someone reports trouble...
2332 } 2305 */
2333 } 2306 ;
2334 } 2307 }
2335 } 2308 }
2336 if (found_entry) { 2309 }
2337 DPRINTK("After vcc was added\n"); 2310 }
2338 dump_arp_table(priv); 2311 if (found_entry) {
2312 DPRINTK("After vcc was added\n");
2313 dump_arp_table(priv);
2339 goto out; 2314 goto out;
2340 } 2315 }
2341 /* Not found, snatch address from first data packet that arrives from 2316 /*
2342 this vcc */ 2317 * Not found, snatch address from first data packet that arrives
2343 entry = make_entry(priv, bus_mac); 2318 * from this vcc
2344 if (!entry) 2319 */
2320 entry = make_entry(priv, bus_mac);
2321 if (!entry)
2345 goto out; 2322 goto out;
2346 entry->vcc = vcc; 2323 entry->vcc = vcc;
2347 entry->old_push = old_push; 2324 entry->old_push = old_push;
2348 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN); 2325 memcpy(entry->atm_addr, ioc_data->atm_addr, ATM_ESA_LEN);
2349 memset(entry->mac_addr, 0, ETH_ALEN); 2326 memset(entry->mac_addr, 0, ETH_ALEN);
2350 entry->status = ESI_UNKNOWN; 2327 entry->status = ESI_UNKNOWN;
2351 entry->next = priv->lec_arp_empty_ones; 2328 hlist_add_head(&entry->next, &priv->lec_arp_empty_ones);
2352 priv->lec_arp_empty_ones = entry; 2329 entry->timer.expires = jiffies + priv->vcc_timeout_period;
2353 entry->timer.expires = jiffies + priv->vcc_timeout_period; 2330 entry->timer.function = lec_arp_expire_vcc;
2354 entry->timer.function = lec_arp_expire_vcc; 2331 add_timer(&entry->timer);
2355 add_timer(&entry->timer); 2332 DPRINTK("After vcc was added\n");
2356 DPRINTK("After vcc was added\n");
2357 dump_arp_table(priv); 2333 dump_arp_table(priv);
2358out: 2334out:
2359 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); 2335 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
2360} 2336}
2361 2337
2362static void 2338static void lec_flush_complete(struct lec_priv *priv, unsigned long tran_id)
2363lec_flush_complete(struct lec_priv *priv, unsigned long tran_id)
2364{ 2339{
2365 unsigned long flags; 2340 unsigned long flags;
2366 struct lec_arp_table *entry; 2341 struct hlist_node *node;
2367 int i; 2342 struct lec_arp_table *entry;
2368 2343 int i;
2369 DPRINTK("LEC:lec_flush_complete %lx\n",tran_id); 2344
2345 DPRINTK("LEC:lec_flush_complete %lx\n", tran_id);
2346restart:
2370 spin_lock_irqsave(&priv->lec_arp_lock, flags); 2347 spin_lock_irqsave(&priv->lec_arp_lock, flags);
2371 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) { 2348 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
2372 for (entry = priv->lec_arp_tables[i]; entry; entry=entry->next) { 2349 hlist_for_each_entry(entry, node, &priv->lec_arp_tables[i], next) {
2373 if (entry->flush_tran_id == tran_id && 2350 if (entry->flush_tran_id == tran_id
2374 entry->status == ESI_FLUSH_PENDING) { 2351 && entry->status == ESI_FLUSH_PENDING) {
2375 struct sk_buff *skb; 2352 struct sk_buff *skb;
2376 2353 struct atm_vcc *vcc = entry->vcc;
2377 while ((skb = skb_dequeue(&entry->tx_wait)) != NULL) 2354
2378 lec_send(entry->vcc, skb, entry->priv); 2355 lec_arp_hold(entry);
2379 entry->status = ESI_FORWARD_DIRECT; 2356 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
2380 DPRINTK("LEC_ARP: Flushed\n"); 2357 while ((skb = skb_dequeue(&entry->tx_wait)) != NULL)
2381 } 2358 lec_send(vcc, skb, entry->priv);
2382 } 2359 entry->last_used = jiffies;
2383 } 2360 entry->status = ESI_FORWARD_DIRECT;
2361 lec_arp_put(entry);
2362 DPRINTK("LEC_ARP: Flushed\n");
2363 goto restart;
2364 }
2365 }
2366 }
2384 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); 2367 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
2385 dump_arp_table(priv); 2368 dump_arp_table(priv);
2386} 2369}
2387 2370
2388static void 2371static void
2389lec_set_flush_tran_id(struct lec_priv *priv, 2372lec_set_flush_tran_id(struct lec_priv *priv,
2390 unsigned char *atm_addr, unsigned long tran_id) 2373 unsigned char *atm_addr, unsigned long tran_id)
2391{ 2374{
2392 unsigned long flags; 2375 unsigned long flags;
2393 struct lec_arp_table *entry; 2376 struct hlist_node *node;
2394 int i; 2377 struct lec_arp_table *entry;
2378 int i;
2395 2379
2396 spin_lock_irqsave(&priv->lec_arp_lock, flags); 2380 spin_lock_irqsave(&priv->lec_arp_lock, flags);
2397 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) 2381 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++)
2398 for(entry = priv->lec_arp_tables[i]; entry; entry=entry->next) 2382 hlist_for_each_entry(entry, node, &priv->lec_arp_tables[i], next) {
2399 if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN)) { 2383 if (!memcmp(atm_addr, entry->atm_addr, ATM_ESA_LEN)) {
2400 entry->flush_tran_id = tran_id; 2384 entry->flush_tran_id = tran_id;
2401 DPRINTK("Set flush transaction id to %lx for %p\n",tran_id,entry); 2385 DPRINTK("Set flush transaction id to %lx for %p\n",
2402 } 2386 tran_id, entry);
2387 }
2388 }
2403 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); 2389 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
2404} 2390}
2405 2391
2406static int 2392static int lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc)
2407lec_mcast_make(struct lec_priv *priv, struct atm_vcc *vcc)
2408{ 2393{
2409 unsigned long flags; 2394 unsigned long flags;
2410 unsigned char mac_addr[] = { 2395 unsigned char mac_addr[] = {
2411 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 2396 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
2412 struct lec_arp_table *to_add; 2397 };
2398 struct lec_arp_table *to_add;
2413 struct lec_vcc_priv *vpriv; 2399 struct lec_vcc_priv *vpriv;
2414 int err = 0; 2400 int err = 0;
2415 2401
2416 if (!(vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL))) 2402 if (!(vpriv = kmalloc(sizeof(struct lec_vcc_priv), GFP_KERNEL)))
2417 return -ENOMEM; 2403 return -ENOMEM;
2418 vpriv->xoff = 0; 2404 vpriv->xoff = 0;
2419 vpriv->old_pop = vcc->pop; 2405 vpriv->old_pop = vcc->pop;
2420 vcc->user_back = vpriv; 2406 vcc->user_back = vpriv;
2421 vcc->pop = lec_pop; 2407 vcc->pop = lec_pop;
2422 spin_lock_irqsave(&priv->lec_arp_lock, flags); 2408 spin_lock_irqsave(&priv->lec_arp_lock, flags);
2423 to_add = make_entry(priv, mac_addr); 2409 to_add = make_entry(priv, mac_addr);
2424 if (!to_add) { 2410 if (!to_add) {
2425 vcc->pop = vpriv->old_pop; 2411 vcc->pop = vpriv->old_pop;
2426 kfree(vpriv); 2412 kfree(vpriv);
2427 err = -ENOMEM; 2413 err = -ENOMEM;
2428 goto out; 2414 goto out;
2429 } 2415 }
2430 memcpy(to_add->atm_addr, vcc->remote.sas_addr.prv, ATM_ESA_LEN); 2416 memcpy(to_add->atm_addr, vcc->remote.sas_addr.prv, ATM_ESA_LEN);
2431 to_add->status = ESI_FORWARD_DIRECT; 2417 to_add->status = ESI_FORWARD_DIRECT;
2432 to_add->flags |= LEC_PERMANENT_FLAG; 2418 to_add->flags |= LEC_PERMANENT_FLAG;
2433 to_add->vcc = vcc; 2419 to_add->vcc = vcc;
2434 to_add->old_push = vcc->push; 2420 to_add->old_push = vcc->push;
2435 vcc->push = lec_push; 2421 vcc->push = lec_push;
2436 priv->mcast_vcc = vcc; 2422 priv->mcast_vcc = vcc;
2437 lec_arp_add(priv, to_add); 2423 lec_arp_add(priv, to_add);
2438out: 2424out:
2439 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); 2425 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
2440 return err; 2426 return err;
2441} 2427}
2442 2428
2443static void 2429static void lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc)
2444lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc)
2445{ 2430{
2446 unsigned long flags; 2431 unsigned long flags;
2447 struct lec_arp_table *entry, *next; 2432 struct hlist_node *node, *next;
2448 int i; 2433 struct lec_arp_table *entry;
2434 int i;
2435
2436 DPRINTK("LEC_ARP: lec_vcc_close vpi:%d vci:%d\n", vcc->vpi, vcc->vci);
2437 dump_arp_table(priv);
2449 2438
2450 DPRINTK("LEC_ARP: lec_vcc_close vpi:%d vci:%d\n",vcc->vpi,vcc->vci);
2451 dump_arp_table(priv);
2452 spin_lock_irqsave(&priv->lec_arp_lock, flags); 2439 spin_lock_irqsave(&priv->lec_arp_lock, flags);
2453 for(i=0;i<LEC_ARP_TABLE_SIZE;i++) { 2440
2454 for(entry = priv->lec_arp_tables[i];entry; entry=next) { 2441 for (i = 0; i < LEC_ARP_TABLE_SIZE; i++) {
2455 next = entry->next; 2442 hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_tables[i], next) {
2456 if (vcc == entry->vcc) { 2443 if (vcc == entry->vcc) {
2457 lec_arp_remove(priv, entry); 2444 lec_arp_remove(priv, entry);
2458 kfree(entry); 2445 lec_arp_put(entry);
2459 if (priv->mcast_vcc == vcc) { 2446 if (priv->mcast_vcc == vcc) {
2460 priv->mcast_vcc = NULL; 2447 priv->mcast_vcc = NULL;
2461 } 2448 }
2462 } 2449 }
2463 } 2450 }
2464 } 2451 }
2465 2452
2466 entry = priv->lec_arp_empty_ones; 2453 hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_empty_ones, next) {
2467 priv->lec_arp_empty_ones = NULL; 2454 if (entry->vcc == vcc) {
2468 while (entry != NULL) { 2455 lec_arp_clear_vccs(entry);
2469 next = entry->next; 2456 del_timer(&entry->timer);
2470 if (entry->vcc == vcc) { /* leave it out from the list */ 2457 hlist_del(&entry->next);
2471 lec_arp_clear_vccs(entry); 2458 lec_arp_put(entry);
2472 del_timer(&entry->timer); 2459 }
2473 kfree(entry); 2460 }
2474 } 2461
2475 else { /* put it back to the list */ 2462 hlist_for_each_entry_safe(entry, node, next, &priv->lec_no_forward, next) {
2476 entry->next = priv->lec_arp_empty_ones; 2463 if (entry->recv_vcc == vcc) {
2477 priv->lec_arp_empty_ones = entry; 2464 lec_arp_clear_vccs(entry);
2478 } 2465 del_timer(&entry->timer);
2479 entry = next; 2466 hlist_del(&entry->next);
2480 } 2467 lec_arp_put(entry);
2481 2468 }
2482 entry = priv->lec_no_forward; 2469 }
2483 priv->lec_no_forward = NULL; 2470
2484 while (entry != NULL) { 2471 hlist_for_each_entry_safe(entry, node, next, &priv->mcast_fwds, next) {
2485 next = entry->next; 2472 if (entry->recv_vcc == vcc) {
2486 if (entry->recv_vcc == vcc) { 2473 lec_arp_clear_vccs(entry);
2487 lec_arp_clear_vccs(entry); 2474 /* No timer, LANEv2 7.1.20 and 2.3.5.3 */
2488 del_timer(&entry->timer); 2475 hlist_del(&entry->next);
2489 kfree(entry); 2476 lec_arp_put(entry);
2490 } 2477 }
2491 else { 2478 }
2492 entry->next = priv->lec_no_forward;
2493 priv->lec_no_forward = entry;
2494 }
2495 entry = next;
2496 }
2497
2498 entry = priv->mcast_fwds;
2499 priv->mcast_fwds = NULL;
2500 while (entry != NULL) {
2501 next = entry->next;
2502 if (entry->recv_vcc == vcc) {
2503 lec_arp_clear_vccs(entry);
2504 /* No timer, LANEv2 7.1.20 and 2.3.5.3 */
2505 kfree(entry);
2506 }
2507 else {
2508 entry->next = priv->mcast_fwds;
2509 priv->mcast_fwds = entry;
2510 }
2511 entry = next;
2512 }
2513 2479
2514 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); 2480 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
2515 dump_arp_table(priv); 2481 dump_arp_table(priv);
@@ -2517,57 +2483,42 @@ lec_vcc_close(struct lec_priv *priv, struct atm_vcc *vcc)
2517 2483
2518static void 2484static void
2519lec_arp_check_empties(struct lec_priv *priv, 2485lec_arp_check_empties(struct lec_priv *priv,
2520 struct atm_vcc *vcc, struct sk_buff *skb) 2486 struct atm_vcc *vcc, struct sk_buff *skb)
2521{ 2487{
2522 unsigned long flags; 2488 unsigned long flags;
2523 struct lec_arp_table *entry, *prev; 2489 struct hlist_node *node, *next;
2524 struct lecdatahdr_8023 *hdr = (struct lecdatahdr_8023 *)skb->data; 2490 struct lec_arp_table *entry, *tmp;
2525 unsigned char *src; 2491 struct lecdatahdr_8023 *hdr = (struct lecdatahdr_8023 *)skb->data;
2492 unsigned char *src;
2526#ifdef CONFIG_TR 2493#ifdef CONFIG_TR
2527 struct lecdatahdr_8025 *tr_hdr = (struct lecdatahdr_8025 *)skb->data; 2494 struct lecdatahdr_8025 *tr_hdr = (struct lecdatahdr_8025 *)skb->data;
2528 2495
2529 if (priv->is_trdev) src = tr_hdr->h_source; 2496 if (priv->is_trdev)
2530 else 2497 src = tr_hdr->h_source;
2498 else
2531#endif 2499#endif
2532 src = hdr->h_source; 2500 src = hdr->h_source;
2533 2501
2534 spin_lock_irqsave(&priv->lec_arp_lock, flags); 2502 spin_lock_irqsave(&priv->lec_arp_lock, flags);
2535 entry = priv->lec_arp_empty_ones; 2503 hlist_for_each_entry_safe(entry, node, next, &priv->lec_arp_empty_ones, next) {
2536 if (vcc == entry->vcc) { 2504 if (vcc == entry->vcc) {
2537 del_timer(&entry->timer); 2505 del_timer(&entry->timer);
2538 memcpy(entry->mac_addr, src, ETH_ALEN); 2506 memcpy(entry->mac_addr, src, ETH_ALEN);
2539 entry->status = ESI_FORWARD_DIRECT; 2507 entry->status = ESI_FORWARD_DIRECT;
2540 entry->last_used = jiffies; 2508 entry->last_used = jiffies;
2541 priv->lec_arp_empty_ones = entry->next; 2509 /* We might have got an entry */
2542 /* We might have got an entry */ 2510 if ((tmp = lec_arp_find(priv, src))) {
2543 if ((prev = lec_arp_find(priv,src))) { 2511 lec_arp_remove(priv, tmp);
2544 lec_arp_remove(priv, prev); 2512 lec_arp_put(tmp);
2545 kfree(prev); 2513 }
2546 } 2514 hlist_del(&entry->next);
2547 lec_arp_add(priv, entry); 2515 lec_arp_add(priv, entry);
2548 goto out; 2516 goto out;
2549 } 2517 }
2550 prev = entry; 2518 }
2551 entry = entry->next; 2519 DPRINTK("LEC_ARP: Arp_check_empties: entry not found!\n");
2552 while (entry && entry->vcc != vcc) {
2553 prev= entry;
2554 entry = entry->next;
2555 }
2556 if (!entry) {
2557 DPRINTK("LEC_ARP: Arp_check_empties: entry not found!\n");
2558 goto out;
2559 }
2560 del_timer(&entry->timer);
2561 memcpy(entry->mac_addr, src, ETH_ALEN);
2562 entry->status = ESI_FORWARD_DIRECT;
2563 entry->last_used = jiffies;
2564 prev->next = entry->next;
2565 if ((prev = lec_arp_find(priv, src))) {
2566 lec_arp_remove(priv, prev);
2567 kfree(prev);
2568 }
2569 lec_arp_add(priv, entry);
2570out: 2520out:
2571 spin_unlock_irqrestore(&priv->lec_arp_lock, flags); 2521 spin_unlock_irqrestore(&priv->lec_arp_lock, flags);
2572} 2522}
2523
2573MODULE_LICENSE("GPL"); 2524MODULE_LICENSE("GPL");
diff --git a/net/atm/lec.h b/net/atm/lec.h
index c22a8bfa1f81..8ac6b7321635 100644
--- a/net/atm/lec.h
+++ b/net/atm/lec.h
@@ -1,14 +1,13 @@
1/* 1/*
2 *
3 * Lan Emulation client header file 2 * Lan Emulation client header file
4 * 3 *
5 * Marko Kiiskila mkiiskila@yahoo.com 4 * Marko Kiiskila <mkiiskila@yahoo.com>
6 *
7 */ 5 */
8 6
9#ifndef _LEC_H_ 7#ifndef _LEC_H_
10#define _LEC_H_ 8#define _LEC_H_
11 9
10#include <linux/config.h>
12#include <linux/atmdev.h> 11#include <linux/atmdev.h>
13#include <linux/netdevice.h> 12#include <linux/netdevice.h>
14#include <linux/atmlec.h> 13#include <linux/atmlec.h>
@@ -16,18 +15,18 @@
16#define LEC_HEADER_LEN 16 15#define LEC_HEADER_LEN 16
17 16
18struct lecdatahdr_8023 { 17struct lecdatahdr_8023 {
19 unsigned short le_header; 18 unsigned short le_header;
20 unsigned char h_dest[ETH_ALEN]; 19 unsigned char h_dest[ETH_ALEN];
21 unsigned char h_source[ETH_ALEN]; 20 unsigned char h_source[ETH_ALEN];
22 unsigned short h_type; 21 unsigned short h_type;
23}; 22};
24 23
25struct lecdatahdr_8025 { 24struct lecdatahdr_8025 {
26 unsigned short le_header; 25 unsigned short le_header;
27 unsigned char ac_pad; 26 unsigned char ac_pad;
28 unsigned char fc; 27 unsigned char fc;
29 unsigned char h_dest[ETH_ALEN]; 28 unsigned char h_dest[ETH_ALEN];
30 unsigned char h_source[ETH_ALEN]; 29 unsigned char h_source[ETH_ALEN];
31}; 30};
32 31
33#define LEC_MINIMUM_8023_SIZE 62 32#define LEC_MINIMUM_8023_SIZE 62
@@ -44,17 +43,18 @@ struct lecdatahdr_8025 {
44 * 43 *
45 */ 44 */
46struct lane2_ops { 45struct lane2_ops {
47 int (*resolve)(struct net_device *dev, u8 *dst_mac, int force, 46 int (*resolve) (struct net_device *dev, u8 *dst_mac, int force,
48 u8 **tlvs, u32 *sizeoftlvs); 47 u8 **tlvs, u32 *sizeoftlvs);
49 int (*associate_req)(struct net_device *dev, u8 *lan_dst, 48 int (*associate_req) (struct net_device *dev, u8 *lan_dst,
50 u8 *tlvs, u32 sizeoftlvs); 49 u8 *tlvs, u32 sizeoftlvs);
51 void (*associate_indicator)(struct net_device *dev, u8 *mac_addr, 50 void (*associate_indicator) (struct net_device *dev, u8 *mac_addr,
52 u8 *tlvs, u32 sizeoftlvs); 51 u8 *tlvs, u32 sizeoftlvs);
53}; 52};
54 53
55/* 54/*
56 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType 55 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
57 * frames. 56 * frames.
57 *
58 * 1. Dix Ethernet EtherType frames encoded by placing EtherType 58 * 1. Dix Ethernet EtherType frames encoded by placing EtherType
59 * field in h_type field. Data follows immediatelly after header. 59 * field in h_type field. Data follows immediatelly after header.
60 * 2. LLC Data frames whose total length, including LLC field and data, 60 * 2. LLC Data frames whose total length, including LLC field and data,
@@ -70,72 +70,88 @@ struct lane2_ops {
70#define LEC_ARP_TABLE_SIZE 16 70#define LEC_ARP_TABLE_SIZE 16
71 71
72struct lec_priv { 72struct lec_priv {
73 struct net_device_stats stats; 73 struct net_device_stats stats;
74 unsigned short lecid; /* Lecid of this client */ 74 unsigned short lecid; /* Lecid of this client */
75 struct lec_arp_table *lec_arp_empty_ones; 75 struct hlist_head lec_arp_empty_ones;
76 /* Used for storing VCC's that don't have a MAC address attached yet */ 76 /* Used for storing VCC's that don't have a MAC address attached yet */
77 struct lec_arp_table *lec_arp_tables[LEC_ARP_TABLE_SIZE]; 77 struct hlist_head lec_arp_tables[LEC_ARP_TABLE_SIZE];
78 /* Actual LE ARP table */ 78 /* Actual LE ARP table */
79 struct lec_arp_table *lec_no_forward; 79 struct hlist_head lec_no_forward;
80 /* Used for storing VCC's (and forward packets from) which are to 80 /*
81 age out by not using them to forward packets. 81 * Used for storing VCC's (and forward packets from) which are to
82 This is because to some LE clients there will be 2 VCCs. Only 82 * age out by not using them to forward packets.
83 one of them gets used. */ 83 * This is because to some LE clients there will be 2 VCCs. Only
84 struct lec_arp_table *mcast_fwds; 84 * one of them gets used.
85 /* With LANEv2 it is possible that BUS (or a special multicast server) 85 */
86 establishes multiple Multicast Forward VCCs to us. This list 86 struct hlist_head mcast_fwds;
87 collects all those VCCs. LANEv1 client has only one item in this 87 /*
88 list. These entries are not aged out. */ 88 * With LANEv2 it is possible that BUS (or a special multicast server)
89 spinlock_t lec_arp_lock; 89 * establishes multiple Multicast Forward VCCs to us. This list
90 struct atm_vcc *mcast_vcc; /* Default Multicast Send VCC */ 90 * collects all those VCCs. LANEv1 client has only one item in this
91 struct atm_vcc *lecd; 91 * list. These entries are not aged out.
92 struct timer_list lec_arp_timer; 92 */
93 /* C10 */ 93 spinlock_t lec_arp_lock;
94 unsigned int maximum_unknown_frame_count; 94 struct atm_vcc *mcast_vcc; /* Default Multicast Send VCC */
95/* Within the period of time defined by this variable, the client will send 95 struct atm_vcc *lecd;
96 no more than C10 frames to BUS for a given unicast destination. (C11) */ 96 struct work_struct lec_arp_work; /* C10 */
97 unsigned long max_unknown_frame_time; 97 unsigned int maximum_unknown_frame_count;
98/* If no traffic has been sent in this vcc for this period of time, 98 /*
99 vcc will be torn down (C12)*/ 99 * Within the period of time defined by this variable, the client will send
100 unsigned long vcc_timeout_period; 100 * no more than C10 frames to BUS for a given unicast destination. (C11)
101/* An LE Client MUST not retry an LE_ARP_REQUEST for a 101 */
102 given frame's LAN Destination more than maximum retry count times, 102 unsigned long max_unknown_frame_time;
103 after the first LEC_ARP_REQUEST (C13)*/ 103 /*
104 unsigned short max_retry_count; 104 * If no traffic has been sent in this vcc for this period of time,
105/* Max time the client will maintain an entry in its arp cache in 105 * vcc will be torn down (C12)
106 absence of a verification of that relationship (C17)*/ 106 */
107 unsigned long aging_time; 107 unsigned long vcc_timeout_period;
108/* Max time the client will maintain an entry in cache when 108 /*
109 topology change flag is true (C18) */ 109 * An LE Client MUST not retry an LE_ARP_REQUEST for a
110 unsigned long forward_delay_time; 110 * given frame's LAN Destination more than maximum retry count times,
111/* Topology change flag (C19)*/ 111 * after the first LEC_ARP_REQUEST (C13)
112 int topology_change; 112 */
113/* Max time the client expects an LE_ARP_REQUEST/LE_ARP_RESPONSE 113 unsigned short max_retry_count;
114 cycle to take (C20)*/ 114 /*
115 unsigned long arp_response_time; 115 * Max time the client will maintain an entry in its arp cache in
116/* Time limit ot wait to receive an LE_FLUSH_RESPONSE after the 116 * absence of a verification of that relationship (C17)
117 LE_FLUSH_REQUEST has been sent before taking recover action. (C21)*/ 117 */
118 unsigned long flush_timeout; 118 unsigned long aging_time;
119/* The time since sending a frame to the bus after which the 119 /*
120 LE Client may assume that the frame has been either discarded or 120 * Max time the client will maintain an entry in cache when
121 delivered to the recipient (C22) */ 121 * topology change flag is true (C18)
122 unsigned long path_switching_delay; 122 */
123 unsigned long forward_delay_time; /* Topology change flag (C19) */
124 int topology_change;
125 /*
126 * Max time the client expects an LE_ARP_REQUEST/LE_ARP_RESPONSE
127 * cycle to take (C20)
128 */
129 unsigned long arp_response_time;
130 /*
131 * Time limit ot wait to receive an LE_FLUSH_RESPONSE after the
132 * LE_FLUSH_REQUEST has been sent before taking recover action. (C21)
133 */
134 unsigned long flush_timeout;
135 /* The time since sending a frame to the bus after which the
136 * LE Client may assume that the frame has been either discarded or
137 * delivered to the recipient (C22)
138 */
139 unsigned long path_switching_delay;
123 140
124 u8 *tlvs; /* LANE2: TLVs are new */ 141 u8 *tlvs; /* LANE2: TLVs are new */
125 u32 sizeoftlvs; /* The size of the tlv array in bytes */ 142 u32 sizeoftlvs; /* The size of the tlv array in bytes */
126 int lane_version; /* LANE2 */ 143 int lane_version; /* LANE2 */
127 int itfnum; /* e.g. 2 for lec2, 5 for lec5 */ 144 int itfnum; /* e.g. 2 for lec2, 5 for lec5 */
128 struct lane2_ops *lane2_ops; /* can be NULL for LANE v1 */ 145 struct lane2_ops *lane2_ops; /* can be NULL for LANE v1 */
129 int is_proxy; /* bridge between ATM and Ethernet */ 146 int is_proxy; /* bridge between ATM and Ethernet */
130 int is_trdev; /* Device type, 0 = Ethernet, 1 = TokenRing */ 147 int is_trdev; /* Device type, 0 = Ethernet, 1 = TokenRing */
131}; 148};
132 149
133struct lec_vcc_priv { 150struct lec_vcc_priv {
134 void (*old_pop)(struct atm_vcc *vcc, struct sk_buff *skb); 151 void (*old_pop) (struct atm_vcc *vcc, struct sk_buff *skb);
135 int xoff; 152 int xoff;
136}; 153};
137 154
138#define LEC_VCC_PRIV(vcc) ((struct lec_vcc_priv *)((vcc)->user_back)) 155#define LEC_VCC_PRIV(vcc) ((struct lec_vcc_priv *)((vcc)->user_back))
139 156
140#endif /* _LEC_H_ */ 157#endif /* _LEC_H_ */
141
diff --git a/net/atm/lec_arpc.h b/net/atm/lec_arpc.h
index 397448094648..ec67435a40a6 100644
--- a/net/atm/lec_arpc.h
+++ b/net/atm/lec_arpc.h
@@ -1,92 +1,96 @@
1/* 1/*
2 * Lec arp cache 2 * Lec arp cache
3 * Marko Kiiskila mkiiskila@yahoo.com
4 * 3 *
4 * Marko Kiiskila <mkiiskila@yahoo.com>
5 */ 5 */
6#ifndef _LEC_ARP_H 6#ifndef _LEC_ARP_H_
7#define _LEC_ARP_H 7#define _LEC_ARP_H_
8#include <linux/atm.h> 8#include <linux/atm.h>
9#include <linux/atmdev.h> 9#include <linux/atmdev.h>
10#include <linux/if_ether.h> 10#include <linux/if_ether.h>
11#include <linux/atmlec.h> 11#include <linux/atmlec.h>
12 12
13struct lec_arp_table { 13struct lec_arp_table {
14 struct lec_arp_table *next; /* Linked entry list */ 14 struct hlist_node next; /* Linked entry list */
15 unsigned char atm_addr[ATM_ESA_LEN]; /* Atm address */ 15 unsigned char atm_addr[ATM_ESA_LEN]; /* Atm address */
16 unsigned char mac_addr[ETH_ALEN]; /* Mac address */ 16 unsigned char mac_addr[ETH_ALEN]; /* Mac address */
17 int is_rdesc; /* Mac address is a route descriptor */ 17 int is_rdesc; /* Mac address is a route descriptor */
18 struct atm_vcc *vcc; /* Vcc this entry is attached */ 18 struct atm_vcc *vcc; /* Vcc this entry is attached */
19 struct atm_vcc *recv_vcc; /* Vcc we receive data from */ 19 struct atm_vcc *recv_vcc; /* Vcc we receive data from */
20 void (*old_push)(struct atm_vcc *vcc,struct sk_buff *skb);
21 /* Push that leads to daemon */
22 void (*old_recv_push)(struct atm_vcc *vcc, struct sk_buff *skb);
23 /* Push that leads to daemon */
24 void (*old_close)(struct atm_vcc *vcc);
25 /* We want to see when this
26 * vcc gets closed */
27 unsigned long last_used; /* For expiry */
28 unsigned long timestamp; /* Used for various timestamping
29 * things:
30 * 1. FLUSH started
31 * (status=ESI_FLUSH_PENDING)
32 * 2. Counting to
33 * max_unknown_frame_time
34 * (status=ESI_ARP_PENDING||
35 * status=ESI_VC_PENDING)
36 */
37 unsigned char no_tries; /* No of times arp retry has been
38 tried */
39 unsigned char status; /* Status of this entry */
40 unsigned short flags; /* Flags for this entry */
41 unsigned short packets_flooded; /* Data packets flooded */
42 unsigned long flush_tran_id; /* Transaction id in flush protocol */
43 struct timer_list timer; /* Arping timer */
44 struct lec_priv *priv; /* Pointer back */
45 20
46 u8 *tlvs; /* LANE2: Each MAC address can have TLVs */ 21 void (*old_push) (struct atm_vcc *vcc, struct sk_buff *skb);
47 u32 sizeoftlvs; /* associated with it. sizeoftlvs tells the */ 22 /* Push that leads to daemon */
48 /* the length of the tlvs array */ 23
49 struct sk_buff_head tx_wait; /* wait queue for outgoing packets */ 24 void (*old_recv_push) (struct atm_vcc *vcc, struct sk_buff *skb);
25 /* Push that leads to daemon */
26
27 unsigned long last_used; /* For expiry */
28 unsigned long timestamp; /* Used for various timestamping things:
29 * 1. FLUSH started
30 * (status=ESI_FLUSH_PENDING)
31 * 2. Counting to
32 * max_unknown_frame_time
33 * (status=ESI_ARP_PENDING||
34 * status=ESI_VC_PENDING)
35 */
36 unsigned char no_tries; /* No of times arp retry has been tried */
37 unsigned char status; /* Status of this entry */
38 unsigned short flags; /* Flags for this entry */
39 unsigned short packets_flooded; /* Data packets flooded */
40 unsigned long flush_tran_id; /* Transaction id in flush protocol */
41 struct timer_list timer; /* Arping timer */
42 struct lec_priv *priv; /* Pointer back */
43 u8 *tlvs;
44 u32 sizeoftlvs; /*
45 * LANE2: Each MAC address can have TLVs
46 * associated with it. sizeoftlvs tells the
47 * the length of the tlvs array
48 */
49 struct sk_buff_head tx_wait; /* wait queue for outgoing packets */
50 atomic_t usage; /* usage count */
50}; 51};
51 52
52struct tlv { /* LANE2: Template tlv struct for accessing */ 53/*
53 /* the tlvs in the lec_arp_table->tlvs array*/ 54 * LANE2: Template tlv struct for accessing
54 u32 type; 55 * the tlvs in the lec_arp_table->tlvs array
55 u8 length; 56 */
56 u8 value[255]; 57struct tlv {
58 u32 type;
59 u8 length;
60 u8 value[255];
57}; 61};
58 62
59/* Status fields */ 63/* Status fields */
60#define ESI_UNKNOWN 0 /* 64#define ESI_UNKNOWN 0 /*
61 * Next packet sent to this mac address 65 * Next packet sent to this mac address
62 * causes ARP-request to be sent 66 * causes ARP-request to be sent
63 */ 67 */
64#define ESI_ARP_PENDING 1 /* 68#define ESI_ARP_PENDING 1 /*
65 * There is no ATM address associated with this 69 * There is no ATM address associated with this
66 * 48-bit address. The LE-ARP protocol is in 70 * 48-bit address. The LE-ARP protocol is in
67 * progress. 71 * progress.
68 */ 72 */
69#define ESI_VC_PENDING 2 /* 73#define ESI_VC_PENDING 2 /*
70 * There is a valid ATM address associated with 74 * There is a valid ATM address associated with
71 * this 48-bit address but there is no VC set 75 * this 48-bit address but there is no VC set
72 * up to that ATM address. The signaling 76 * up to that ATM address. The signaling
73 * protocol is in process. 77 * protocol is in process.
74 */ 78 */
75#define ESI_FLUSH_PENDING 4 /* 79#define ESI_FLUSH_PENDING 4 /*
76 * The LEC has been notified of the FLUSH_START 80 * The LEC has been notified of the FLUSH_START
77 * status and it is assumed that the flush 81 * status and it is assumed that the flush
78 * protocol is in process. 82 * protocol is in process.
79 */ 83 */
80#define ESI_FORWARD_DIRECT 5 /* 84#define ESI_FORWARD_DIRECT 5 /*
81 * Either the Path Switching Delay (C22) has 85 * Either the Path Switching Delay (C22) has
82 * elapsed or the LEC has notified the Mapping 86 * elapsed or the LEC has notified the Mapping
83 * that the flush protocol has completed. In 87 * that the flush protocol has completed. In
84 * either case, it is safe to forward packets 88 * either case, it is safe to forward packets
85 * to this address via the data direct VC. 89 * to this address via the data direct VC.
86 */ 90 */
87 91
88/* Flag values */ 92/* Flag values */
89#define LEC_REMOTE_FLAG 0x0001 93#define LEC_REMOTE_FLAG 0x0001
90#define LEC_PERMANENT_FLAG 0x0002 94#define LEC_PERMANENT_FLAG 0x0002
91 95
92#endif 96#endif /* _LEC_ARP_H_ */
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index c4e469ff842d..a8e2e879a647 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -485,7 +485,7 @@ doi_add_failure_rlock:
485 * 485 *
486 */ 486 */
487int cipso_v4_doi_remove(u32 doi, 487int cipso_v4_doi_remove(u32 doi,
488 u32 audit_secid, 488 struct netlbl_audit *audit_info,
489 void (*callback) (struct rcu_head * head)) 489 void (*callback) (struct rcu_head * head))
490{ 490{
491 struct cipso_v4_doi *doi_def; 491 struct cipso_v4_doi *doi_def;
@@ -506,7 +506,7 @@ int cipso_v4_doi_remove(u32 doi,
506 list_for_each_entry_rcu(dom_iter, &doi_def->dom_list, list) 506 list_for_each_entry_rcu(dom_iter, &doi_def->dom_list, list)
507 if (dom_iter->valid) 507 if (dom_iter->valid)
508 netlbl_domhsh_remove(dom_iter->domain, 508 netlbl_domhsh_remove(dom_iter->domain,
509 audit_secid); 509 audit_info);
510 cipso_v4_cache_invalidate(); 510 cipso_v4_cache_invalidate();
511 rcu_read_unlock(); 511 rcu_read_unlock();
512 512
diff --git a/net/netlabel/netlabel_cipso_v4.c b/net/netlabel/netlabel_cipso_v4.c
index 09986ca962a6..a6ce1d6d5c59 100644
--- a/net/netlabel/netlabel_cipso_v4.c
+++ b/net/netlabel/netlabel_cipso_v4.c
@@ -384,11 +384,15 @@ static int netlbl_cipsov4_add(struct sk_buff *skb, struct genl_info *info)
384 u32 doi; 384 u32 doi;
385 const char *type_str = "(unknown)"; 385 const char *type_str = "(unknown)";
386 struct audit_buffer *audit_buf; 386 struct audit_buffer *audit_buf;
387 struct netlbl_audit audit_info;
387 388
388 if (!info->attrs[NLBL_CIPSOV4_A_DOI] || 389 if (!info->attrs[NLBL_CIPSOV4_A_DOI] ||
389 !info->attrs[NLBL_CIPSOV4_A_MTYPE]) 390 !info->attrs[NLBL_CIPSOV4_A_MTYPE])
390 return -EINVAL; 391 return -EINVAL;
391 392
393 doi = nla_get_u32(info->attrs[NLBL_CIPSOV4_A_DOI]);
394 netlbl_netlink_auditinfo(skb, &audit_info);
395
392 type = nla_get_u32(info->attrs[NLBL_CIPSOV4_A_MTYPE]); 396 type = nla_get_u32(info->attrs[NLBL_CIPSOV4_A_MTYPE]);
393 switch (type) { 397 switch (type) {
394 case CIPSO_V4_MAP_STD: 398 case CIPSO_V4_MAP_STD:
@@ -401,13 +405,14 @@ static int netlbl_cipsov4_add(struct sk_buff *skb, struct genl_info *info)
401 break; 405 break;
402 } 406 }
403 407
404 if (ret_val == 0) { 408 audit_buf = netlbl_audit_start_common(AUDIT_MAC_CIPSOV4_ADD,
405 doi = nla_get_u32(info->attrs[NLBL_CIPSOV4_A_DOI]); 409 &audit_info);
406 audit_buf = netlbl_audit_start_common(AUDIT_MAC_CIPSOV4_ADD, 410 audit_log_format(audit_buf,
407 NETLINK_CB(skb).sid); 411 " cipso_doi=%u cipso_type=%s res=%u",
408 audit_log_format(audit_buf, " doi=%u type=%s", doi, type_str); 412 doi,
409 audit_log_end(audit_buf); 413 type_str,
410 } 414 ret_val == 0 ? 1 : 0);
415 audit_log_end(audit_buf);
411 416
412 return ret_val; 417 return ret_val;
413} 418}
@@ -668,20 +673,25 @@ static int netlbl_cipsov4_remove(struct sk_buff *skb, struct genl_info *info)
668 int ret_val = -EINVAL; 673 int ret_val = -EINVAL;
669 u32 doi = 0; 674 u32 doi = 0;
670 struct audit_buffer *audit_buf; 675 struct audit_buffer *audit_buf;
676 struct netlbl_audit audit_info;
671 677
672 if (info->attrs[NLBL_CIPSOV4_A_DOI]) { 678 if (!info->attrs[NLBL_CIPSOV4_A_DOI])
673 doi = nla_get_u32(info->attrs[NLBL_CIPSOV4_A_DOI]); 679 return -EINVAL;
674 ret_val = cipso_v4_doi_remove(doi,
675 NETLINK_CB(skb).sid,
676 netlbl_cipsov4_doi_free);
677 }
678 680
679 if (ret_val == 0) { 681 doi = nla_get_u32(info->attrs[NLBL_CIPSOV4_A_DOI]);
680 audit_buf = netlbl_audit_start_common(AUDIT_MAC_CIPSOV4_DEL, 682 netlbl_netlink_auditinfo(skb, &audit_info);
681 NETLINK_CB(skb).sid); 683
682 audit_log_format(audit_buf, " doi=%u", doi); 684 ret_val = cipso_v4_doi_remove(doi,
683 audit_log_end(audit_buf); 685 &audit_info,
684 } 686 netlbl_cipsov4_doi_free);
687
688 audit_buf = netlbl_audit_start_common(AUDIT_MAC_CIPSOV4_DEL,
689 &audit_info);
690 audit_log_format(audit_buf,
691 " cipso_doi=%u res=%u",
692 doi,
693 ret_val == 0 ? 1 : 0);
694 audit_log_end(audit_buf);
685 695
686 return ret_val; 696 return ret_val;
687} 697}
diff --git a/net/netlabel/netlabel_domainhash.c b/net/netlabel/netlabel_domainhash.c
index d64e2ae3b129..af4371d3b459 100644
--- a/net/netlabel/netlabel_domainhash.c
+++ b/net/netlabel/netlabel_domainhash.c
@@ -188,7 +188,7 @@ int netlbl_domhsh_init(u32 size)
188/** 188/**
189 * netlbl_domhsh_add - Adds a entry to the domain hash table 189 * netlbl_domhsh_add - Adds a entry to the domain hash table
190 * @entry: the entry to add 190 * @entry: the entry to add
191 * @audit_secid: the LSM secid to use in the audit message 191 * @audit_info: NetLabel audit information
192 * 192 *
193 * Description: 193 * Description:
194 * Adds a new entry to the domain hash table and handles any updates to the 194 * Adds a new entry to the domain hash table and handles any updates to the
@@ -196,7 +196,8 @@ int netlbl_domhsh_init(u32 size)
196 * negative on failure. 196 * negative on failure.
197 * 197 *
198 */ 198 */
199int netlbl_domhsh_add(struct netlbl_dom_map *entry, u32 audit_secid) 199int netlbl_domhsh_add(struct netlbl_dom_map *entry,
200 struct netlbl_audit *audit_info)
200{ 201{
201 int ret_val; 202 int ret_val;
202 u32 bkt; 203 u32 bkt;
@@ -241,26 +242,26 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry, u32 audit_secid)
241 spin_unlock(&netlbl_domhsh_def_lock); 242 spin_unlock(&netlbl_domhsh_def_lock);
242 } else 243 } else
243 ret_val = -EINVAL; 244 ret_val = -EINVAL;
244 if (ret_val == 0) { 245
245 if (entry->domain != NULL) 246 if (entry->domain != NULL)
246 audit_domain = entry->domain; 247 audit_domain = entry->domain;
247 else 248 else
248 audit_domain = "(default)"; 249 audit_domain = "(default)";
249 audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_ADD, 250 audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_ADD, audit_info);
250 audit_secid); 251 audit_log_format(audit_buf, " nlbl_domain=%s", audit_domain);
251 audit_log_format(audit_buf, " domain=%s", audit_domain); 252 switch (entry->type) {
252 switch (entry->type) { 253 case NETLBL_NLTYPE_UNLABELED:
253 case NETLBL_NLTYPE_UNLABELED: 254 audit_log_format(audit_buf, " nlbl_protocol=unlbl");
254 audit_log_format(audit_buf, " protocol=unlbl"); 255 break;
255 break; 256 case NETLBL_NLTYPE_CIPSOV4:
256 case NETLBL_NLTYPE_CIPSOV4: 257 audit_log_format(audit_buf,
257 audit_log_format(audit_buf, 258 " nlbl_protocol=cipsov4 cipso_doi=%u",
258 " protocol=cipsov4 doi=%u", 259 entry->type_def.cipsov4->doi);
259 entry->type_def.cipsov4->doi); 260 break;
260 break;
261 }
262 audit_log_end(audit_buf);
263 } 261 }
262 audit_log_format(audit_buf, " res=%u", ret_val == 0 ? 1 : 0);
263 audit_log_end(audit_buf);
264
264 rcu_read_unlock(); 265 rcu_read_unlock();
265 266
266 if (ret_val != 0) { 267 if (ret_val != 0) {
@@ -279,7 +280,7 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry, u32 audit_secid)
279/** 280/**
280 * netlbl_domhsh_add_default - Adds the default entry to the domain hash table 281 * netlbl_domhsh_add_default - Adds the default entry to the domain hash table
281 * @entry: the entry to add 282 * @entry: the entry to add
282 * @audit_secid: the LSM secid to use in the audit message 283 * @audit_info: NetLabel audit information
283 * 284 *
284 * Description: 285 * Description:
285 * Adds a new default entry to the domain hash table and handles any updates 286 * Adds a new default entry to the domain hash table and handles any updates
@@ -287,15 +288,16 @@ int netlbl_domhsh_add(struct netlbl_dom_map *entry, u32 audit_secid)
287 * negative on failure. 288 * negative on failure.
288 * 289 *
289 */ 290 */
290int netlbl_domhsh_add_default(struct netlbl_dom_map *entry, u32 audit_secid) 291int netlbl_domhsh_add_default(struct netlbl_dom_map *entry,
292 struct netlbl_audit *audit_info)
291{ 293{
292 return netlbl_domhsh_add(entry, audit_secid); 294 return netlbl_domhsh_add(entry, audit_info);
293} 295}
294 296
295/** 297/**
296 * netlbl_domhsh_remove - Removes an entry from the domain hash table 298 * netlbl_domhsh_remove - Removes an entry from the domain hash table
297 * @domain: the domain to remove 299 * @domain: the domain to remove
298 * @audit_secid: the LSM secid to use in the audit message 300 * @audit_info: NetLabel audit information
299 * 301 *
300 * Description: 302 * Description:
301 * Removes an entry from the domain hash table and handles any updates to the 303 * Removes an entry from the domain hash table and handles any updates to the
@@ -303,7 +305,7 @@ int netlbl_domhsh_add_default(struct netlbl_dom_map *entry, u32 audit_secid)
303 * negative on failure. 305 * negative on failure.
304 * 306 *
305 */ 307 */
306int netlbl_domhsh_remove(const char *domain, u32 audit_secid) 308int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info)
307{ 309{
308 int ret_val = -ENOENT; 310 int ret_val = -ENOENT;
309 struct netlbl_dom_map *entry; 311 struct netlbl_dom_map *entry;
@@ -345,18 +347,20 @@ int netlbl_domhsh_remove(const char *domain, u32 audit_secid)
345 ret_val = -ENOENT; 347 ret_val = -ENOENT;
346 spin_unlock(&netlbl_domhsh_def_lock); 348 spin_unlock(&netlbl_domhsh_def_lock);
347 } 349 }
348 if (ret_val == 0) {
349 if (entry->domain != NULL)
350 audit_domain = entry->domain;
351 else
352 audit_domain = "(default)";
353 audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_DEL,
354 audit_secid);
355 audit_log_format(audit_buf, " domain=%s", audit_domain);
356 audit_log_end(audit_buf);
357 350
351 if (entry->domain != NULL)
352 audit_domain = entry->domain;
353 else
354 audit_domain = "(default)";
355 audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_DEL, audit_info);
356 audit_log_format(audit_buf,
357 " nlbl_domain=%s res=%u",
358 audit_domain,
359 ret_val == 0 ? 1 : 0);
360 audit_log_end(audit_buf);
361
362 if (ret_val == 0)
358 call_rcu(&entry->rcu, netlbl_domhsh_free_entry); 363 call_rcu(&entry->rcu, netlbl_domhsh_free_entry);
359 }
360 364
361remove_return: 365remove_return:
362 rcu_read_unlock(); 366 rcu_read_unlock();
@@ -365,7 +369,7 @@ remove_return:
365 369
366/** 370/**
367 * netlbl_domhsh_remove_default - Removes the default entry from the table 371 * netlbl_domhsh_remove_default - Removes the default entry from the table
368 * @audit_secid: the LSM secid to use in the audit message 372 * @audit_info: NetLabel audit information
369 * 373 *
370 * Description: 374 * Description:
371 * Removes/resets the default entry for the domain hash table and handles any 375 * Removes/resets the default entry for the domain hash table and handles any
@@ -373,9 +377,9 @@ remove_return:
373 * success, non-zero on failure. 377 * success, non-zero on failure.
374 * 378 *
375 */ 379 */
376int netlbl_domhsh_remove_default(u32 audit_secid) 380int netlbl_domhsh_remove_default(struct netlbl_audit *audit_info)
377{ 381{
378 return netlbl_domhsh_remove(NULL, audit_secid); 382 return netlbl_domhsh_remove(NULL, audit_info);
379} 383}
380 384
381/** 385/**
diff --git a/net/netlabel/netlabel_domainhash.h b/net/netlabel/netlabel_domainhash.h
index d50f13cacdca..3689956c3436 100644
--- a/net/netlabel/netlabel_domainhash.h
+++ b/net/netlabel/netlabel_domainhash.h
@@ -57,9 +57,11 @@ struct netlbl_dom_map {
57int netlbl_domhsh_init(u32 size); 57int netlbl_domhsh_init(u32 size);
58 58
59/* Manipulate the domain hash table */ 59/* Manipulate the domain hash table */
60int netlbl_domhsh_add(struct netlbl_dom_map *entry, u32 audit_secid); 60int netlbl_domhsh_add(struct netlbl_dom_map *entry,
61int netlbl_domhsh_add_default(struct netlbl_dom_map *entry, u32 audit_secid); 61 struct netlbl_audit *audit_info);
62int netlbl_domhsh_remove_default(u32 audit_secid); 62int netlbl_domhsh_add_default(struct netlbl_dom_map *entry,
63 struct netlbl_audit *audit_info);
64int netlbl_domhsh_remove_default(struct netlbl_audit *audit_info);
63struct netlbl_dom_map *netlbl_domhsh_getentry(const char *domain); 65struct netlbl_dom_map *netlbl_domhsh_getentry(const char *domain);
64int netlbl_domhsh_walk(u32 *skip_bkt, 66int netlbl_domhsh_walk(u32 *skip_bkt,
65 u32 *skip_chain, 67 u32 *skip_chain,
diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
index 0ac314f18ad1..53c9079ad2c3 100644
--- a/net/netlabel/netlabel_mgmt.c
+++ b/net/netlabel/netlabel_mgmt.c
@@ -87,11 +87,14 @@ static int netlbl_mgmt_add(struct sk_buff *skb, struct genl_info *info)
87 struct netlbl_dom_map *entry = NULL; 87 struct netlbl_dom_map *entry = NULL;
88 size_t tmp_size; 88 size_t tmp_size;
89 u32 tmp_val; 89 u32 tmp_val;
90 struct netlbl_audit audit_info;
90 91
91 if (!info->attrs[NLBL_MGMT_A_DOMAIN] || 92 if (!info->attrs[NLBL_MGMT_A_DOMAIN] ||
92 !info->attrs[NLBL_MGMT_A_PROTOCOL]) 93 !info->attrs[NLBL_MGMT_A_PROTOCOL])
93 goto add_failure; 94 goto add_failure;
94 95
96 netlbl_netlink_auditinfo(skb, &audit_info);
97
95 entry = kzalloc(sizeof(*entry), GFP_KERNEL); 98 entry = kzalloc(sizeof(*entry), GFP_KERNEL);
96 if (entry == NULL) { 99 if (entry == NULL) {
97 ret_val = -ENOMEM; 100 ret_val = -ENOMEM;
@@ -108,7 +111,7 @@ static int netlbl_mgmt_add(struct sk_buff *skb, struct genl_info *info)
108 111
109 switch (entry->type) { 112 switch (entry->type) {
110 case NETLBL_NLTYPE_UNLABELED: 113 case NETLBL_NLTYPE_UNLABELED:
111 ret_val = netlbl_domhsh_add(entry, NETLINK_CB(skb).sid); 114 ret_val = netlbl_domhsh_add(entry, &audit_info);
112 break; 115 break;
113 case NETLBL_NLTYPE_CIPSOV4: 116 case NETLBL_NLTYPE_CIPSOV4:
114 if (!info->attrs[NLBL_MGMT_A_CV4DOI]) 117 if (!info->attrs[NLBL_MGMT_A_CV4DOI])
@@ -125,7 +128,7 @@ static int netlbl_mgmt_add(struct sk_buff *skb, struct genl_info *info)
125 rcu_read_unlock(); 128 rcu_read_unlock();
126 goto add_failure; 129 goto add_failure;
127 } 130 }
128 ret_val = netlbl_domhsh_add(entry, NETLINK_CB(skb).sid); 131 ret_val = netlbl_domhsh_add(entry, &audit_info);
129 rcu_read_unlock(); 132 rcu_read_unlock();
130 break; 133 break;
131 default: 134 default:
@@ -156,12 +159,15 @@ add_failure:
156static int netlbl_mgmt_remove(struct sk_buff *skb, struct genl_info *info) 159static int netlbl_mgmt_remove(struct sk_buff *skb, struct genl_info *info)
157{ 160{
158 char *domain; 161 char *domain;
162 struct netlbl_audit audit_info;
159 163
160 if (!info->attrs[NLBL_MGMT_A_DOMAIN]) 164 if (!info->attrs[NLBL_MGMT_A_DOMAIN])
161 return -EINVAL; 165 return -EINVAL;
162 166
167 netlbl_netlink_auditinfo(skb, &audit_info);
168
163 domain = nla_data(info->attrs[NLBL_MGMT_A_DOMAIN]); 169 domain = nla_data(info->attrs[NLBL_MGMT_A_DOMAIN]);
164 return netlbl_domhsh_remove(domain, NETLINK_CB(skb).sid); 170 return netlbl_domhsh_remove(domain, &audit_info);
165} 171}
166 172
167/** 173/**
@@ -264,10 +270,13 @@ static int netlbl_mgmt_adddef(struct sk_buff *skb, struct genl_info *info)
264 int ret_val = -EINVAL; 270 int ret_val = -EINVAL;
265 struct netlbl_dom_map *entry = NULL; 271 struct netlbl_dom_map *entry = NULL;
266 u32 tmp_val; 272 u32 tmp_val;
273 struct netlbl_audit audit_info;
267 274
268 if (!info->attrs[NLBL_MGMT_A_PROTOCOL]) 275 if (!info->attrs[NLBL_MGMT_A_PROTOCOL])
269 goto adddef_failure; 276 goto adddef_failure;
270 277
278 netlbl_netlink_auditinfo(skb, &audit_info);
279
271 entry = kzalloc(sizeof(*entry), GFP_KERNEL); 280 entry = kzalloc(sizeof(*entry), GFP_KERNEL);
272 if (entry == NULL) { 281 if (entry == NULL) {
273 ret_val = -ENOMEM; 282 ret_val = -ENOMEM;
@@ -277,8 +286,7 @@ static int netlbl_mgmt_adddef(struct sk_buff *skb, struct genl_info *info)
277 286
278 switch (entry->type) { 287 switch (entry->type) {
279 case NETLBL_NLTYPE_UNLABELED: 288 case NETLBL_NLTYPE_UNLABELED:
280 ret_val = netlbl_domhsh_add_default(entry, 289 ret_val = netlbl_domhsh_add_default(entry, &audit_info);
281 NETLINK_CB(skb).sid);
282 break; 290 break;
283 case NETLBL_NLTYPE_CIPSOV4: 291 case NETLBL_NLTYPE_CIPSOV4:
284 if (!info->attrs[NLBL_MGMT_A_CV4DOI]) 292 if (!info->attrs[NLBL_MGMT_A_CV4DOI])
@@ -295,8 +303,7 @@ static int netlbl_mgmt_adddef(struct sk_buff *skb, struct genl_info *info)
295 rcu_read_unlock(); 303 rcu_read_unlock();
296 goto adddef_failure; 304 goto adddef_failure;
297 } 305 }
298 ret_val = netlbl_domhsh_add_default(entry, 306 ret_val = netlbl_domhsh_add_default(entry, &audit_info);
299 NETLINK_CB(skb).sid);
300 rcu_read_unlock(); 307 rcu_read_unlock();
301 break; 308 break;
302 default: 309 default:
@@ -324,7 +331,11 @@ adddef_failure:
324 */ 331 */
325static int netlbl_mgmt_removedef(struct sk_buff *skb, struct genl_info *info) 332static int netlbl_mgmt_removedef(struct sk_buff *skb, struct genl_info *info)
326{ 333{
327 return netlbl_domhsh_remove_default(NETLINK_CB(skb).sid); 334 struct netlbl_audit audit_info;
335
336 netlbl_netlink_auditinfo(skb, &audit_info);
337
338 return netlbl_domhsh_remove_default(&audit_info);
328} 339}
329 340
330/** 341/**
diff --git a/net/netlabel/netlabel_unlabeled.c b/net/netlabel/netlabel_unlabeled.c
index ab36675fee8c..1833ad233b39 100644
--- a/net/netlabel/netlabel_unlabeled.c
+++ b/net/netlabel/netlabel_unlabeled.c
@@ -70,18 +70,25 @@ static struct nla_policy netlbl_unlabel_genl_policy[NLBL_UNLABEL_A_MAX + 1] = {
70/** 70/**
71 * netlbl_unlabel_acceptflg_set - Set the unlabeled accept flag 71 * netlbl_unlabel_acceptflg_set - Set the unlabeled accept flag
72 * @value: desired value 72 * @value: desired value
73 * @audit_secid: the LSM secid to use in the audit message 73 * @audit_info: NetLabel audit information
74 * 74 *
75 * Description: 75 * Description:
76 * Set the value of the unlabeled accept flag to @value. 76 * Set the value of the unlabeled accept flag to @value.
77 * 77 *
78 */ 78 */
79static void netlbl_unlabel_acceptflg_set(u8 value, u32 audit_secid) 79static void netlbl_unlabel_acceptflg_set(u8 value,
80 struct netlbl_audit *audit_info)
80{ 81{
82 struct audit_buffer *audit_buf;
83 u8 old_val;
84
85 old_val = atomic_read(&netlabel_unlabel_accept_flg);
81 atomic_set(&netlabel_unlabel_accept_flg, value); 86 atomic_set(&netlabel_unlabel_accept_flg, value);
82 netlbl_audit_nomsg((value ? 87
83 AUDIT_MAC_UNLBL_ACCEPT : AUDIT_MAC_UNLBL_DENY), 88 audit_buf = netlbl_audit_start_common(AUDIT_MAC_UNLBL_ALLOW,
84 audit_secid); 89 audit_info);
90 audit_log_format(audit_buf, " unlbl_accept=%u old=%u", value, old_val);
91 audit_log_end(audit_buf);
85} 92}
86 93
87/* 94/*
@@ -101,12 +108,13 @@ static void netlbl_unlabel_acceptflg_set(u8 value, u32 audit_secid)
101static int netlbl_unlabel_accept(struct sk_buff *skb, struct genl_info *info) 108static int netlbl_unlabel_accept(struct sk_buff *skb, struct genl_info *info)
102{ 109{
103 u8 value; 110 u8 value;
111 struct netlbl_audit audit_info;
104 112
105 if (info->attrs[NLBL_UNLABEL_A_ACPTFLG]) { 113 if (info->attrs[NLBL_UNLABEL_A_ACPTFLG]) {
106 value = nla_get_u8(info->attrs[NLBL_UNLABEL_A_ACPTFLG]); 114 value = nla_get_u8(info->attrs[NLBL_UNLABEL_A_ACPTFLG]);
107 if (value == 1 || value == 0) { 115 if (value == 1 || value == 0) {
108 netlbl_unlabel_acceptflg_set(value, 116 netlbl_netlink_auditinfo(skb, &audit_info);
109 NETLINK_CB(skb).sid); 117 netlbl_unlabel_acceptflg_set(value, &audit_info);
110 return 0; 118 return 0;
111 } 119 }
112 } 120 }
@@ -250,19 +258,23 @@ int netlbl_unlabel_defconf(void)
250{ 258{
251 int ret_val; 259 int ret_val;
252 struct netlbl_dom_map *entry; 260 struct netlbl_dom_map *entry;
253 u32 secid; 261 struct netlbl_audit audit_info;
254 262
255 security_task_getsecid(current, &secid); 263 /* Only the kernel is allowed to call this function and the only time
264 * it is called is at bootup before the audit subsystem is reporting
265 * messages so don't worry to much about these values. */
266 security_task_getsecid(current, &audit_info.secid);
267 audit_info.loginuid = 0;
256 268
257 entry = kzalloc(sizeof(*entry), GFP_KERNEL); 269 entry = kzalloc(sizeof(*entry), GFP_KERNEL);
258 if (entry == NULL) 270 if (entry == NULL)
259 return -ENOMEM; 271 return -ENOMEM;
260 entry->type = NETLBL_NLTYPE_UNLABELED; 272 entry->type = NETLBL_NLTYPE_UNLABELED;
261 ret_val = netlbl_domhsh_add_default(entry, secid); 273 ret_val = netlbl_domhsh_add_default(entry, &audit_info);
262 if (ret_val != 0) 274 if (ret_val != 0)
263 return ret_val; 275 return ret_val;
264 276
265 netlbl_unlabel_acceptflg_set(1, secid); 277 netlbl_unlabel_acceptflg_set(1, &audit_info);
266 278
267 return 0; 279 return 0;
268} 280}
diff --git a/net/netlabel/netlabel_user.c b/net/netlabel/netlabel_user.c
index c2343af584cb..98a416381e61 100644
--- a/net/netlabel/netlabel_user.c
+++ b/net/netlabel/netlabel_user.c
@@ -85,7 +85,7 @@ int netlbl_netlink_init(void)
85/** 85/**
86 * netlbl_audit_start_common - Start an audit message 86 * netlbl_audit_start_common - Start an audit message
87 * @type: audit message type 87 * @type: audit message type
88 * @secid: LSM context ID 88 * @audit_info: NetLabel audit information
89 * 89 *
90 * Description: 90 * Description:
91 * Start an audit message using the type specified in @type and fill the audit 91 * Start an audit message using the type specified in @type and fill the audit
@@ -93,14 +93,11 @@ int netlbl_netlink_init(void)
93 * a pointer to the audit buffer on success, NULL on failure. 93 * a pointer to the audit buffer on success, NULL on failure.
94 * 94 *
95 */ 95 */
96struct audit_buffer *netlbl_audit_start_common(int type, u32 secid) 96struct audit_buffer *netlbl_audit_start_common(int type,
97 struct netlbl_audit *audit_info)
97{ 98{
98 struct audit_context *audit_ctx = current->audit_context; 99 struct audit_context *audit_ctx = current->audit_context;
99 struct audit_buffer *audit_buf; 100 struct audit_buffer *audit_buf;
100 uid_t audit_loginuid;
101 const char *audit_tty;
102 char audit_comm[sizeof(current->comm)];
103 struct vm_area_struct *vma;
104 char *secctx; 101 char *secctx;
105 u32 secctx_len; 102 u32 secctx_len;
106 103
@@ -108,60 +105,13 @@ struct audit_buffer *netlbl_audit_start_common(int type, u32 secid)
108 if (audit_buf == NULL) 105 if (audit_buf == NULL)
109 return NULL; 106 return NULL;
110 107
111 audit_loginuid = audit_get_loginuid(audit_ctx); 108 audit_log_format(audit_buf, "netlabel: auid=%u", audit_info->loginuid);
112 if (current->signal &&
113 current->signal->tty &&
114 current->signal->tty->name)
115 audit_tty = current->signal->tty->name;
116 else
117 audit_tty = "(none)";
118 get_task_comm(audit_comm, current);
119 109
120 audit_log_format(audit_buf, 110 if (audit_info->secid != 0 &&
121 "netlabel: auid=%u uid=%u tty=%s pid=%d", 111 security_secid_to_secctx(audit_info->secid,
122 audit_loginuid, 112 &secctx,
123 current->uid, 113 &secctx_len) == 0)
124 audit_tty,
125 current->pid);
126 audit_log_format(audit_buf, " comm=");
127 audit_log_untrustedstring(audit_buf, audit_comm);
128 if (current->mm) {
129 down_read(&current->mm->mmap_sem);
130 vma = current->mm->mmap;
131 while (vma) {
132 if ((vma->vm_flags & VM_EXECUTABLE) &&
133 vma->vm_file) {
134 audit_log_d_path(audit_buf,
135 " exe=",
136 vma->vm_file->f_dentry,
137 vma->vm_file->f_vfsmnt);
138 break;
139 }
140 vma = vma->vm_next;
141 }
142 up_read(&current->mm->mmap_sem);
143 }
144
145 if (secid != 0 &&
146 security_secid_to_secctx(secid, &secctx, &secctx_len) == 0)
147 audit_log_format(audit_buf, " subj=%s", secctx); 114 audit_log_format(audit_buf, " subj=%s", secctx);
148 115
149 return audit_buf; 116 return audit_buf;
150} 117}
151
152/**
153 * netlbl_audit_nomsg - Send an audit message without additional text
154 * @type: audit message type
155 * @secid: LSM context ID
156 *
157 * Description:
158 * Send an audit message with only the common NetLabel audit fields.
159 *
160 */
161void netlbl_audit_nomsg(int type, u32 secid)
162{
163 struct audit_buffer *audit_buf;
164
165 audit_buf = netlbl_audit_start_common(type, secid);
166 audit_log_end(audit_buf);
167}
diff --git a/net/netlabel/netlabel_user.h b/net/netlabel/netlabel_user.h
index ab840acfc964..47967ef32964 100644
--- a/net/netlabel/netlabel_user.h
+++ b/net/netlabel/netlabel_user.h
@@ -72,13 +72,25 @@ static inline void *netlbl_netlink_hdr_put(struct sk_buff *skb,
72 NETLBL_PROTO_VERSION); 72 NETLBL_PROTO_VERSION);
73} 73}
74 74
75/**
76 * netlbl_netlink_auditinfo - Fetch the audit information from a NETLINK msg
77 * @skb: the packet
78 * @audit_info: NetLabel audit information
79 */
80static inline void netlbl_netlink_auditinfo(struct sk_buff *skb,
81 struct netlbl_audit *audit_info)
82{
83 audit_info->secid = NETLINK_CB(skb).sid;
84 audit_info->loginuid = NETLINK_CB(skb).loginuid;
85}
86
75/* NetLabel NETLINK I/O functions */ 87/* NetLabel NETLINK I/O functions */
76 88
77int netlbl_netlink_init(void); 89int netlbl_netlink_init(void);
78 90
79/* NetLabel Audit Functions */ 91/* NetLabel Audit Functions */
80 92
81struct audit_buffer *netlbl_audit_start_common(int type, u32 secid); 93struct audit_buffer *netlbl_audit_start_common(int type,
82void netlbl_audit_nomsg(int type, u32 secid); 94 struct netlbl_audit *audit_info);
83 95
84#endif 96#endif
diff --git a/net/sctp/input.c b/net/sctp/input.c
index 03f65de75d88..64f630102532 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -218,12 +218,6 @@ int sctp_rcv(struct sk_buff *skb)
218 } 218 }
219 } 219 }
220 220
221 /* SCTP seems to always need a timestamp right now (FIXME) */
222 if (skb->tstamp.off_sec == 0) {
223 __net_timestamp(skb);
224 sock_enable_timestamp(sk);
225 }
226
227 if (!xfrm_policy_check(sk, XFRM_POLICY_IN, skb, family)) 221 if (!xfrm_policy_check(sk, XFRM_POLICY_IN, skb, family))
228 goto discard_release; 222 goto discard_release;
229 nf_reset(skb); 223 nf_reset(skb);
@@ -388,7 +382,7 @@ void sctp_icmp_frag_needed(struct sock *sk, struct sctp_association *asoc,
388 * pmtu discovery on this transport. 382 * pmtu discovery on this transport.
389 */ 383 */
390 t->pathmtu = SCTP_DEFAULT_MINSEGMENT; 384 t->pathmtu = SCTP_DEFAULT_MINSEGMENT;
391 t->param_flags = (t->param_flags & ~SPP_HB) | 385 t->param_flags = (t->param_flags & ~SPP_PMTUD) |
392 SPP_PMTUD_DISABLE; 386 SPP_PMTUD_DISABLE;
393 } else { 387 } else {
394 t->pathmtu = pmtu; 388 t->pathmtu = pmtu;
diff --git a/net/sctp/output.c b/net/sctp/output.c
index cdc5a3936766..3ef4351dd956 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -633,7 +633,7 @@ static sctp_xmit_t sctp_packet_append_data(struct sctp_packet *packet,
633 * data will fit or delay in hopes of bundling a full 633 * data will fit or delay in hopes of bundling a full
634 * sized packet. 634 * sized packet.
635 */ 635 */
636 if (len < asoc->pathmtu - packet->overhead) { 636 if (len < asoc->frag_point) {
637 retval = SCTP_XMIT_NAGLE_DELAY; 637 retval = SCTP_XMIT_NAGLE_DELAY;
638 goto finish; 638 goto finish;
639 } 639 }
@@ -645,7 +645,13 @@ static sctp_xmit_t sctp_packet_append_data(struct sctp_packet *packet,
645 /* Keep track of how many bytes are in flight to the receiver. */ 645 /* Keep track of how many bytes are in flight to the receiver. */
646 asoc->outqueue.outstanding_bytes += datasize; 646 asoc->outqueue.outstanding_bytes += datasize;
647 647
648 /* Update our view of the receiver's rwnd. */ 648 /* Update our view of the receiver's rwnd. Include sk_buff overhead
649 * while updating peer.rwnd so that it reduces the chances of a
650 * receiver running out of receive buffer space even when receive
651 * window is still open. This can happen when a sender is sending
652 * sending small messages.
653 */
654 datasize += sizeof(struct sk_buff);
649 if (datasize < rwnd) 655 if (datasize < rwnd)
650 rwnd -= datasize; 656 rwnd -= datasize;
651 else 657 else
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index 37074a39ecbb..739582415bf6 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -416,7 +416,8 @@ void sctp_retransmit_mark(struct sctp_outq *q,
416 * (Section 7.2.4)), add the data size of those 416 * (Section 7.2.4)), add the data size of those
417 * chunks to the rwnd. 417 * chunks to the rwnd.
418 */ 418 */
419 q->asoc->peer.rwnd += sctp_data_size(chunk); 419 q->asoc->peer.rwnd += (sctp_data_size(chunk) +
420 sizeof(struct sk_buff));
420 q->outstanding_bytes -= sctp_data_size(chunk); 421 q->outstanding_bytes -= sctp_data_size(chunk);
421 transport->flight_size -= sctp_data_size(chunk); 422 transport->flight_size -= sctp_data_size(chunk);
422 423
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 7745bdea7817..507dff72c585 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1447,8 +1447,16 @@ no_hmac:
1447 /* Check to see if the cookie is stale. If there is already 1447 /* Check to see if the cookie is stale. If there is already
1448 * an association, there is no need to check cookie's expiration 1448 * an association, there is no need to check cookie's expiration
1449 * for init collision case of lost COOKIE ACK. 1449 * for init collision case of lost COOKIE ACK.
1450 * If skb has been timestamped, then use the stamp, otherwise
1451 * use current time. This introduces a small possibility that
1452 * that a cookie may be considered expired, but his would only slow
1453 * down the new association establishment instead of every packet.
1450 */ 1454 */
1451 skb_get_timestamp(skb, &tv); 1455 if (sock_flag(ep->base.sk, SOCK_TIMESTAMP))
1456 skb_get_timestamp(skb, &tv);
1457 else
1458 do_gettimeofday(&tv);
1459
1452 if (!asoc && tv_lt(bear_cookie->expiration, tv)) { 1460 if (!asoc && tv_lt(bear_cookie->expiration, tv)) {
1453 __u16 len; 1461 __u16 len;
1454 /* 1462 /*
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 79c3e072cf28..3fe906d65069 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3084,8 +3084,8 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
3084 */ 3084 */
3085 sp->disable_fragments = 0; 3085 sp->disable_fragments = 0;
3086 3086
3087 /* Turn on/off any Nagle-like algorithm. */ 3087 /* Enable Nagle algorithm by default. */
3088 sp->nodelay = 1; 3088 sp->nodelay = 0;
3089 3089
3090 /* Enable by default. */ 3090 /* Enable by default. */
3091 sp->v4mapped = 1; 3091 sp->v4mapped = 1;