aboutsummaryrefslogtreecommitdiffstats
path: root/net/ax25/ax25_ip.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2015-03-03 10:41:47 -0500
committerDavid S. Miller <davem@davemloft.net>2015-03-03 14:44:41 -0500
commit1d5da757da860a6916adbf68b09e868062b4b3b8 (patch)
treedeee80ad76638718a7babc524235ff13f35b2f98 /net/ax25/ax25_ip.c
parentbcc90e3fb132f009e647c9032eab4fedb6399339 (diff)
ax25: Stop using magic neighbour cache operations.
Before the ax25 stack calls dev_queue_xmit it always calls ax25_type_trans which sets skb->protocol to ETH_P_AX25. Which means that by looking at the protocol type it is possible to detect IP packets that have not been munged by the ax25 stack in ndo_start_xmit and call a function to munge them. Rename ax25_neigh_xmit to ax25_ip_xmit and tweak the return type and value to be appropriate for an ndo_start_xmit function. Update all of the ax25 devices to test the protocol type for ETH_P_IP and return ax25_ip_xmit as the first thing they do. This preserves the existing semantics of IP packet processing, but the timing will be a little different as the IP packets now pass through the qdisc layer before reaching the ax25 ip packet processing. Remove the now unnecessary ax25 neighbour table operations. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ax25/ax25_ip.c')
-rw-r--r--net/ax25/ax25_ip.c60
1 files changed, 6 insertions, 54 deletions
diff --git a/net/ax25/ax25_ip.c b/net/ax25/ax25_ip.c
index e030c64ebfb7..8b35af4ef93e 100644
--- a/net/ax25/ax25_ip.c
+++ b/net/ax25/ax25_ip.c
@@ -100,7 +100,7 @@ static int ax25_hard_header(struct sk_buff *skb, struct net_device *dev,
100 return -AX25_HEADER_LEN; /* Unfinished header */ 100 return -AX25_HEADER_LEN; /* Unfinished header */
101} 101}
102 102
103static int ax25_neigh_xmit(struct sk_buff *skb) 103netdev_tx_t ax25_ip_xmit(struct sk_buff *skb)
104{ 104{
105 struct sk_buff *ourskb; 105 struct sk_buff *ourskb;
106 unsigned char *bp = skb->data; 106 unsigned char *bp = skb->data;
@@ -210,56 +210,7 @@ put:
210 if (route) 210 if (route)
211 ax25_put_route(route); 211 ax25_put_route(route);
212 212
213 return 1; 213 return NETDEV_TX_OK;
214}
215
216static int ax25_neigh_output(struct neighbour *neigh, struct sk_buff *skb)
217{
218 /* Except for calling ax25_neigh_xmit instead of
219 * dev_queue_xmit this is neigh_resolve_output.
220 */
221 int rc = 0;
222
223 if (!neigh_event_send(neigh, skb)) {
224 int err;
225 struct net_device *dev = neigh->dev;
226 unsigned int seq;
227
228 do {
229 __skb_pull(skb, skb_network_offset(skb));
230 seq = read_seqbegin(&neigh->ha_lock);
231 err = dev_hard_header(skb, dev, ntohs(skb->protocol),
232 neigh->ha, NULL, skb->len);
233 } while (read_seqretry(&neigh->ha_lock, seq));
234
235 if (err >= 0) {
236 ax25_neigh_xmit(skb);
237 } else
238 goto out_kfree_skb;
239 }
240out:
241 return rc;
242
243out_kfree_skb:
244 rc = -EINVAL;
245 kfree_skb(skb);
246 goto out;
247}
248
249int ax25_neigh_construct(struct neighbour *neigh)
250{
251 /* This trouble could be saved if ax25 would right a proper
252 * dev_queue_xmit function.
253 */
254 struct ax25_neigh_priv *priv = neighbour_priv(neigh);
255
256 if (neigh->tbl->family != AF_INET)
257 return -EINVAL;
258
259 priv->ops = *neigh->ops;
260 priv->ops.output = ax25_neigh_output;
261 priv->ops.connected_output = ax25_neigh_output;
262 return 0;
263} 214}
264 215
265#else /* INET */ 216#else /* INET */
@@ -271,9 +222,10 @@ static int ax25_hard_header(struct sk_buff *skb, struct net_device *dev,
271 return -AX25_HEADER_LEN; 222 return -AX25_HEADER_LEN;
272} 223}
273 224
274int ax25_neigh_construct(struct neighbour *neigh) 225netdev_tx_t ax25_ip_xmit(sturct sk_buff *skb)
275{ 226{
276 return 0; 227 kfree_skb(skb);
228 return NETDEV_TX_OK;
277} 229}
278#endif 230#endif
279 231
@@ -282,5 +234,5 @@ const struct header_ops ax25_header_ops = {
282}; 234};
283 235
284EXPORT_SYMBOL(ax25_header_ops); 236EXPORT_SYMBOL(ax25_header_ops);
285EXPORT_SYMBOL(ax25_neigh_construct); 237EXPORT_SYMBOL(ax25_ip_xmit);
286 238