]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ax25: Stop using magic neighbour cache operations.
authorEric W. Biederman <ebiederm@xmission.com>
Tue, 3 Mar 2015 15:41:47 +0000 (09:41 -0600)
committerDavid S. Miller <davem@davemloft.net>
Tue, 3 Mar 2015 19:44:41 +0000 (14:44 -0500)
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>
drivers/net/hamradio/6pack.c
drivers/net/hamradio/baycom_epp.c
drivers/net/hamradio/bpqether.c
drivers/net/hamradio/dmascc.c
drivers/net/hamradio/hdlcdrv.c
drivers/net/hamradio/mkiss.c
drivers/net/hamradio/scc.c
drivers/net/hamradio/yam.c
include/net/ax25.h
net/ax25/ax25_ip.c

index 0b8393ca8c80134b444e5d3bf69d3ed58552b644..7c4a4151ef0f23fca16b0fd957769c09dc5823d0 100644 (file)
@@ -247,6 +247,9 @@ static netdev_tx_t sp_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct sixpack *sp = netdev_priv(dev);
 
+       if (skb->protocol == htons(ETH_P_IP))
+               return ax25_ip_xmit(skb);
+
        spin_lock_bh(&sp->lock);
        /* We were not busy, so we are now... :-) */
        netif_stop_queue(dev);
@@ -302,7 +305,6 @@ static const struct net_device_ops sp_netdev_ops = {
        .ndo_stop               = sp_close,
        .ndo_start_xmit         = sp_xmit,
        .ndo_set_mac_address    = sp_set_mac_address,
-       .ndo_neigh_construct    = ax25_neigh_construct,
 };
 
 static void sp_setup(struct net_device *dev)
@@ -316,7 +318,6 @@ static void sp_setup(struct net_device *dev)
 
        dev->addr_len           = AX25_ADDR_LEN;
        dev->type               = ARPHRD_AX25;
-       dev->neigh_priv_len     = sizeof(struct ax25_neigh_priv);
        dev->tx_queue_len       = 10;
 
        /* Only activated in AX.25 mode */
index 3539ab392f7dc9af3713a6dfd4ec1e978537f470..83c7cce0d172b205f0b1d96405b6b66eea79ea55 100644 (file)
@@ -772,6 +772,9 @@ static int baycom_send_packet(struct sk_buff *skb, struct net_device *dev)
 {
        struct baycom_state *bc = netdev_priv(dev);
 
+       if (skb->protocol == htons(ETH_P_IP))
+               return ax25_ip_xmit(skb);
+
        if (skb->data[0] != 0) {
                do_kiss_params(bc, skb->data, skb->len);
                dev_kfree_skb(skb);
@@ -1109,7 +1112,6 @@ static const struct net_device_ops baycom_netdev_ops = {
        .ndo_do_ioctl        = baycom_ioctl,
        .ndo_start_xmit      = baycom_send_packet,
        .ndo_set_mac_address = baycom_set_mac_address,
-       .ndo_neigh_construct = ax25_neigh_construct,
 };
 
 /*
@@ -1147,7 +1149,6 @@ static void baycom_probe(struct net_device *dev)
        dev->header_ops = &ax25_header_ops;
        
        dev->type = ARPHRD_AX25;           /* AF_AX25 device */
-       dev->neigh_priv_len = sizeof(struct ax25_neigh_priv);
        dev->hard_header_len = AX25_MAX_HEADER_LEN + AX25_BPQ_HEADER_LEN;
        dev->mtu = AX25_DEF_PACLEN;        /* eth_mtu is the default */
        dev->addr_len = AX25_ADDR_LEN;     /* sizeof an ax.25 address */
index bce105b16ed0771460e1a03205c1bb64b213f2bb..63ff08a26da81b5bafc401fbfeeb710a6b595a64 100644 (file)
@@ -251,6 +251,9 @@ static netdev_tx_t bpq_xmit(struct sk_buff *skb, struct net_device *dev)
        struct net_device *orig_dev;
        int size;
 
+       if (skb->protocol == htons(ETH_P_IP))
+               return ax25_ip_xmit(skb);
+
        /*
         * Just to be *really* sure not to send anything if the interface
         * is down, the ethernet device may have gone.
@@ -469,7 +472,6 @@ static const struct net_device_ops bpq_netdev_ops = {
        .ndo_start_xmit      = bpq_xmit,
        .ndo_set_mac_address = bpq_set_mac_address,
        .ndo_do_ioctl        = bpq_ioctl,
-       .ndo_neigh_construct = ax25_neigh_construct,
 };
 
 static void bpq_setup(struct net_device *dev)
@@ -487,7 +489,6 @@ static void bpq_setup(struct net_device *dev)
 #endif
 
        dev->type            = ARPHRD_AX25;
-       dev->neigh_priv_len  = sizeof(struct ax25_neigh_priv);
        dev->hard_header_len = AX25_MAX_HEADER_LEN + AX25_BPQ_HEADER_LEN;
        dev->mtu             = AX25_DEF_PACLEN;
        dev->addr_len        = AX25_ADDR_LEN;
index abab7be77406387fd8442908bfcbe6989d76d083..c3d37777061631d1c34fb1b1e05f36986bb5f6cc 100644 (file)
@@ -433,7 +433,6 @@ module_exit(dmascc_exit);
 static void __init dev_setup(struct net_device *dev)
 {
        dev->type = ARPHRD_AX25;
-       dev->neigh_priv_len = sizeof(struct ax25_neigh_priv);
        dev->hard_header_len = AX25_MAX_HEADER_LEN;
        dev->mtu = 1500;
        dev->addr_len = AX25_ADDR_LEN;
@@ -448,7 +447,6 @@ static const struct net_device_ops scc_netdev_ops = {
        .ndo_start_xmit = scc_send_packet,
        .ndo_do_ioctl = scc_ioctl,
        .ndo_set_mac_address = scc_set_mac_address,
-       .ndo_neigh_construct = ax25_neigh_construct,
 };
 
 static int __init setup_adapter(int card_base, int type, int n)
@@ -922,6 +920,9 @@ static int scc_send_packet(struct sk_buff *skb, struct net_device *dev)
        unsigned long flags;
        int i;
 
+       if (skb->protocol == htons(ETH_P_IP))
+               return ax25_ip_xmit(skb);
+
        /* Temporarily stop the scheduler feeding us packets */
        netif_stop_queue(dev);
 
index 435868a7b69cdcdde15d05988adb1f66f737fa11..49fe59b180a8619f554d5852202df933fee54871 100644 (file)
@@ -404,6 +404,9 @@ static netdev_tx_t hdlcdrv_send_packet(struct sk_buff *skb,
 {
        struct hdlcdrv_state *sm = netdev_priv(dev);
 
+       if (skb->protocol == htons(ETH_P_IP))
+               return ax25_ip_xmit(skb);
+
        if (skb->data[0] != 0) {
                do_kiss_params(sm, skb->data, skb->len);
                dev_kfree_skb(skb);
@@ -626,7 +629,6 @@ static const struct net_device_ops hdlcdrv_netdev = {
        .ndo_start_xmit = hdlcdrv_send_packet,
        .ndo_do_ioctl   = hdlcdrv_ioctl,
        .ndo_set_mac_address = hdlcdrv_set_mac_address,
-       .ndo_neigh_construct = ax25_neigh_construct,
 };
 
 /*
@@ -677,7 +679,6 @@ static void hdlcdrv_setup(struct net_device *dev)
        dev->header_ops = &ax25_header_ops;
        
        dev->type = ARPHRD_AX25;           /* AF_AX25 device */
-       dev->neigh_priv_len = sizeof(struct ax25_neigh_priv);
        dev->hard_header_len = AX25_MAX_HEADER_LEN + AX25_BPQ_HEADER_LEN;
        dev->mtu = AX25_DEF_PACLEN;        /* eth_mtu is the default */
        dev->addr_len = AX25_ADDR_LEN;     /* sizeof an ax.25 address */
index c12ec2c2b594a79e941ea7a9256c3bc5f8cc8c32..17058c490b7991da485546eb52e9177dc7696efc 100644 (file)
@@ -529,6 +529,9 @@ static netdev_tx_t ax_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        struct mkiss *ax = netdev_priv(dev);
 
+       if (skb->protocol == htons(ETH_P_IP))
+               return ax25_ip_xmit(skb);
+
        if (!netif_running(dev))  {
                printk(KERN_ERR "mkiss: %s: xmit call when iface is down\n", dev->name);
                return NETDEV_TX_BUSY;
@@ -641,7 +644,6 @@ static const struct net_device_ops ax_netdev_ops = {
        .ndo_stop            = ax_close,
        .ndo_start_xmit      = ax_xmit,
        .ndo_set_mac_address = ax_set_mac_address,
-       .ndo_neigh_construct = ax25_neigh_construct,
 };
 
 static void ax_setup(struct net_device *dev)
@@ -651,7 +653,6 @@ static void ax_setup(struct net_device *dev)
        dev->hard_header_len = 0;
        dev->addr_len        = 0;
        dev->type            = ARPHRD_AX25;
-       dev->neigh_priv_len  = sizeof(struct ax25_neigh_priv);
        dev->tx_queue_len    = 10;
        dev->header_ops      = &ax25_header_ops;
        dev->netdev_ops      = &ax_netdev_ops;
index b305f51eb42015316b7943f382165ad36c847408..ce88df33fe17b20237b3f4f2e0c9e1ca7b4b63a3 100644 (file)
@@ -1550,7 +1550,6 @@ static const struct net_device_ops scc_netdev_ops = {
        .ndo_set_mac_address = scc_net_set_mac_address,
        .ndo_get_stats       = scc_net_get_stats,
        .ndo_do_ioctl        = scc_net_ioctl,
-       .ndo_neigh_construct = ax25_neigh_construct,
 };
 
 /* ----> Initialize device <----- */
@@ -1568,7 +1567,6 @@ static void scc_net_setup(struct net_device *dev)
        dev->flags      = 0;
 
        dev->type = ARPHRD_AX25;
-       dev->neigh_priv_len = sizeof(struct ax25_neigh_priv);
        dev->hard_header_len = AX25_MAX_HEADER_LEN + AX25_BPQ_HEADER_LEN;
        dev->mtu = AX25_DEF_PACLEN;
        dev->addr_len = AX25_ADDR_LEN;
@@ -1641,6 +1639,9 @@ static netdev_tx_t scc_net_tx(struct sk_buff *skb, struct net_device *dev)
        unsigned long flags;
        char kisscmd;
 
+       if (skb->protocol == htons(ETH_P_IP))
+               return ax25_ip_xmit(skb);
+
        if (skb->len > scc->stat.bufsize || skb->len < 2) {
                scc->dev_stat.tx_dropped++;     /* bogus frame */
                dev_kfree_skb(skb);
index 89d9da7a0c51eebf7fa4b338d21f8a85119ac3eb..1a4729c36aa49d93f8e536cd98d4731df704621d 100644 (file)
@@ -597,6 +597,9 @@ static netdev_tx_t yam_send_packet(struct sk_buff *skb,
 {
        struct yam_port *yp = netdev_priv(dev);
 
+       if (skb->protocol == htons(ETH_P_IP))
+               return ax25_ip_xmit(skb);
+
        skb_queue_tail(&yp->send_queue, skb);
        dev->trans_start = jiffies;
        return NETDEV_TX_OK;
@@ -1100,7 +1103,6 @@ static const struct net_device_ops yam_netdev_ops = {
        .ndo_start_xmit      = yam_send_packet,
        .ndo_do_ioctl        = yam_ioctl,
        .ndo_set_mac_address = yam_set_mac_address,
-       .ndo_neigh_construct = ax25_neigh_construct,
 };
 
 static void yam_setup(struct net_device *dev)
@@ -1129,7 +1131,6 @@ static void yam_setup(struct net_device *dev)
        dev->header_ops = &ax25_header_ops;
 
        dev->type = ARPHRD_AX25;
-       dev->neigh_priv_len = sizeof(struct ax25_neigh_priv);
        dev->hard_header_len = AX25_MAX_HEADER_LEN;
        dev->mtu = AX25_MTU;
        dev->addr_len = AX25_ADDR_LEN;
index 45feeba7a3250be44e78a1a70b4a7da529a47edf..16a923a3a43a8825d167b75025baca0b1b5d741c 100644 (file)
@@ -367,11 +367,8 @@ int ax25_kiss_rcv(struct sk_buff *, struct net_device *, struct packet_type *,
                  struct net_device *);
 
 /* ax25_ip.c */
-int ax25_neigh_construct(struct neighbour *neigh);
+netdev_tx_t ax25_ip_xmit(struct sk_buff *skb);
 extern const struct header_ops ax25_header_ops;
-struct ax25_neigh_priv {
-       struct neigh_ops ops;
-};
 
 /* ax25_out.c */
 ax25_cb *ax25_send_frame(struct sk_buff *, int, ax25_address *, ax25_address *,
index e030c64ebfb77bfc41ca6edf6b3211b1765485ff..8b35af4ef93e5d29f5fa12306a6cfb61ce7cc84e 100644 (file)
@@ -100,7 +100,7 @@ static int ax25_hard_header(struct sk_buff *skb, struct net_device *dev,
        return -AX25_HEADER_LEN;        /* Unfinished header */
 }
 
-static int ax25_neigh_xmit(struct sk_buff *skb)
+netdev_tx_t ax25_ip_xmit(struct sk_buff *skb)
 {
        struct sk_buff *ourskb;
        unsigned char *bp  = skb->data;
@@ -210,56 +210,7 @@ put:
        if (route)
                ax25_put_route(route);
 
-       return 1;
-}
-
-static int ax25_neigh_output(struct neighbour *neigh, struct sk_buff *skb)
-{
-       /* Except for calling ax25_neigh_xmit instead of
-        * dev_queue_xmit this is neigh_resolve_output.
-        */
-       int rc = 0;
-
-       if (!neigh_event_send(neigh, skb)) {
-               int err;
-               struct net_device *dev = neigh->dev;
-               unsigned int seq;
-
-               do {
-                       __skb_pull(skb, skb_network_offset(skb));
-                       seq = read_seqbegin(&neigh->ha_lock);
-                       err = dev_hard_header(skb, dev, ntohs(skb->protocol),
-                                             neigh->ha, NULL, skb->len);
-               } while (read_seqretry(&neigh->ha_lock, seq));
-
-               if (err >= 0) {
-                       ax25_neigh_xmit(skb);
-               } else
-                       goto out_kfree_skb;
-       }
-out:
-       return rc;
-
-out_kfree_skb:
-       rc = -EINVAL;
-       kfree_skb(skb);
-       goto out;
-}
-
-int ax25_neigh_construct(struct neighbour *neigh)
-{
-       /* This trouble could be saved if ax25 would right a proper
-        * dev_queue_xmit function.
-        */
-       struct ax25_neigh_priv *priv = neighbour_priv(neigh);
-
-       if (neigh->tbl->family != AF_INET)
-               return -EINVAL;
-
-       priv->ops = *neigh->ops;
-       priv->ops.output = ax25_neigh_output;
-       priv->ops.connected_output = ax25_neigh_output;
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 #else  /* INET */
@@ -271,9 +222,10 @@ static int ax25_hard_header(struct sk_buff *skb, struct net_device *dev,
        return -AX25_HEADER_LEN;
 }
 
-int ax25_neigh_construct(struct neighbour *neigh)
+netdev_tx_t ax25_ip_xmit(sturct sk_buff *skb)
 {
-       return 0;
+       kfree_skb(skb);
+       return NETDEV_TX_OK;
 }
 #endif
 
@@ -282,5 +234,5 @@ const struct header_ops ax25_header_ops = {
 };
 
 EXPORT_SYMBOL(ax25_header_ops);
-EXPORT_SYMBOL(ax25_neigh_construct);
+EXPORT_SYMBOL(ax25_ip_xmit);