diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /net/tipc/eth_media.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'net/tipc/eth_media.c')
-rw-r--r-- | net/tipc/eth_media.c | 63 |
1 files changed, 36 insertions, 27 deletions
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c index 6230d16020c4..b69092eb95d8 100644 --- a/net/tipc/eth_media.c +++ b/net/tipc/eth_media.c | |||
@@ -34,12 +34,8 @@ | |||
34 | * POSSIBILITY OF SUCH DAMAGE. | 34 | * POSSIBILITY OF SUCH DAMAGE. |
35 | */ | 35 | */ |
36 | 36 | ||
37 | #include <net/tipc/tipc.h> | 37 | #include "core.h" |
38 | #include <net/tipc/tipc_bearer.h> | 38 | #include "bearer.h" |
39 | #include <net/tipc/tipc_msg.h> | ||
40 | #include <linux/netdevice.h> | ||
41 | #include <linux/slab.h> | ||
42 | #include <net/net_namespace.h> | ||
43 | 39 | ||
44 | #define MAX_ETH_BEARERS 2 | 40 | #define MAX_ETH_BEARERS 2 |
45 | #define ETH_LINK_PRIORITY TIPC_DEF_LINK_PRI | 41 | #define ETH_LINK_PRIORITY TIPC_DEF_LINK_PRI |
@@ -60,7 +56,7 @@ struct eth_bearer { | |||
60 | }; | 56 | }; |
61 | 57 | ||
62 | static struct eth_bearer eth_bearers[MAX_ETH_BEARERS]; | 58 | static struct eth_bearer eth_bearers[MAX_ETH_BEARERS]; |
63 | static int eth_started = 0; | 59 | static int eth_started; |
64 | static struct notifier_block notifier; | 60 | static struct notifier_block notifier; |
65 | 61 | ||
66 | /** | 62 | /** |
@@ -72,17 +68,26 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, | |||
72 | { | 68 | { |
73 | struct sk_buff *clone; | 69 | struct sk_buff *clone; |
74 | struct net_device *dev; | 70 | struct net_device *dev; |
71 | int delta; | ||
75 | 72 | ||
76 | clone = skb_clone(buf, GFP_ATOMIC); | 73 | clone = skb_clone(buf, GFP_ATOMIC); |
77 | if (clone) { | 74 | if (!clone) |
78 | skb_reset_network_header(clone); | 75 | return 0; |
79 | dev = ((struct eth_bearer *)(tb_ptr->usr_handle))->dev; | 76 | |
80 | clone->dev = dev; | 77 | dev = ((struct eth_bearer *)(tb_ptr->usr_handle))->dev; |
81 | dev_hard_header(clone, dev, ETH_P_TIPC, | 78 | delta = dev->hard_header_len - skb_headroom(buf); |
82 | &dest->dev_addr.eth_addr, | 79 | |
83 | dev->dev_addr, clone->len); | 80 | if ((delta > 0) && |
84 | dev_queue_xmit(clone); | 81 | pskb_expand_head(clone, SKB_DATA_ALIGN(delta), 0, GFP_ATOMIC)) { |
82 | kfree_skb(clone); | ||
83 | return 0; | ||
85 | } | 84 | } |
85 | |||
86 | skb_reset_network_header(clone); | ||
87 | clone->dev = dev; | ||
88 | dev_hard_header(clone, dev, ETH_P_TIPC, &dest->dev_addr.eth_addr, | ||
89 | dev->dev_addr, clone->len); | ||
90 | dev_queue_xmit(clone); | ||
86 | return 0; | 91 | return 0; |
87 | } | 92 | } |
88 | 93 | ||
@@ -92,15 +97,12 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, | |||
92 | * Accept only packets explicitly sent to this node, or broadcast packets; | 97 | * Accept only packets explicitly sent to this node, or broadcast packets; |
93 | * ignores packets sent using Ethernet multicast, and traffic sent to other | 98 | * ignores packets sent using Ethernet multicast, and traffic sent to other |
94 | * nodes (which can happen if interface is running in promiscuous mode). | 99 | * nodes (which can happen if interface is running in promiscuous mode). |
95 | * Routine truncates any Ethernet padding/CRC appended to the message, | ||
96 | * and ensures message size matches actual length | ||
97 | */ | 100 | */ |
98 | 101 | ||
99 | static int recv_msg(struct sk_buff *buf, struct net_device *dev, | 102 | static int recv_msg(struct sk_buff *buf, struct net_device *dev, |
100 | struct packet_type *pt, struct net_device *orig_dev) | 103 | struct packet_type *pt, struct net_device *orig_dev) |
101 | { | 104 | { |
102 | struct eth_bearer *eb_ptr = (struct eth_bearer *)pt->af_packet_priv; | 105 | struct eth_bearer *eb_ptr = (struct eth_bearer *)pt->af_packet_priv; |
103 | u32 size; | ||
104 | 106 | ||
105 | if (!net_eq(dev_net(dev), &init_net)) { | 107 | if (!net_eq(dev_net(dev), &init_net)) { |
106 | kfree_skb(buf); | 108 | kfree_skb(buf); |
@@ -109,13 +111,9 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev, | |||
109 | 111 | ||
110 | if (likely(eb_ptr->bearer)) { | 112 | if (likely(eb_ptr->bearer)) { |
111 | if (likely(buf->pkt_type <= PACKET_BROADCAST)) { | 113 | if (likely(buf->pkt_type <= PACKET_BROADCAST)) { |
112 | size = msg_size((struct tipc_msg *)buf->data); | 114 | buf->next = NULL; |
113 | skb_trim(buf, size); | 115 | tipc_recv_msg(buf, eb_ptr->bearer); |
114 | if (likely(buf->len == size)) { | 116 | return 0; |
115 | buf->next = NULL; | ||
116 | tipc_recv_msg(buf, eb_ptr->bearer); | ||
117 | return 0; | ||
118 | } | ||
119 | } | 117 | } |
120 | } | 118 | } |
121 | kfree_skb(buf); | 119 | kfree_skb(buf); |
@@ -133,10 +131,20 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) | |||
133 | struct eth_bearer *eb_ptr = ð_bearers[0]; | 131 | struct eth_bearer *eb_ptr = ð_bearers[0]; |
134 | struct eth_bearer *stop = ð_bearers[MAX_ETH_BEARERS]; | 132 | struct eth_bearer *stop = ð_bearers[MAX_ETH_BEARERS]; |
135 | char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1; | 133 | char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1; |
134 | int pending_dev = 0; | ||
135 | |||
136 | /* Find unused Ethernet bearer structure */ | ||
137 | |||
138 | while (eb_ptr->dev) { | ||
139 | if (!eb_ptr->bearer) | ||
140 | pending_dev++; | ||
141 | if (++eb_ptr == stop) | ||
142 | return pending_dev ? -EAGAIN : -EDQUOT; | ||
143 | } | ||
136 | 144 | ||
137 | /* Find device with specified name */ | 145 | /* Find device with specified name */ |
138 | 146 | ||
139 | for_each_netdev(&init_net, pdev){ | 147 | for_each_netdev(&init_net, pdev) { |
140 | if (!strncmp(pdev->name, driver_name, IFNAMSIZ)) { | 148 | if (!strncmp(pdev->name, driver_name, IFNAMSIZ)) { |
141 | dev = pdev; | 149 | dev = pdev; |
142 | break; | 150 | break; |
@@ -147,7 +155,8 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) | |||
147 | 155 | ||
148 | /* Find Ethernet bearer for device (or create one) */ | 156 | /* Find Ethernet bearer for device (or create one) */ |
149 | 157 | ||
150 | for (;(eb_ptr != stop) && eb_ptr->dev && (eb_ptr->dev != dev); eb_ptr++); | 158 | while ((eb_ptr != stop) && eb_ptr->dev && (eb_ptr->dev != dev)) |
159 | eb_ptr++; | ||
151 | if (eb_ptr == stop) | 160 | if (eb_ptr == stop) |
152 | return -EDQUOT; | 161 | return -EDQUOT; |
153 | if (!eb_ptr->dev) { | 162 | if (!eb_ptr->dev) { |