[NET]: Move hardware header operations out of netdevice.
authorStephen Hemminger <shemminger@linux-foundation.org>
Tue, 9 Oct 2007 08:40:57 +0000 (01:40 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Wed, 10 Oct 2007 23:52:52 +0000 (16:52 -0700)
Since hardware header operations are part of the protocol class
not the device instance, make them into a separate object and
save memory.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
65 files changed:
drivers/ieee1394/eth1394.c
drivers/infiniband/ulp/ipoib/ipoib_main.c
drivers/isdn/i4l/isdn_net.c
drivers/media/dvb/dvb-core/dvb_net.c
drivers/net/appletalk/cops.c
drivers/net/appletalk/ltpc.c
drivers/net/arcnet/arcnet.c
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
drivers/net/loopback.c
drivers/net/macvlan.c
drivers/net/myri_sbus.c
drivers/net/plip.c
drivers/net/shaper.c
drivers/net/skfp/skfddi.c
drivers/net/wan/cycx_x25.c
drivers/net/wan/dlci.c
drivers/net/wan/hdlc.c
drivers/net/wan/hdlc_cisco.c
drivers/net/wan/hdlc_ppp.c
drivers/net/wan/lmc/lmc_proto.c
drivers/net/wan/syncppp.c
drivers/net/wireless/airo.c
drivers/net/wireless/hostap/hostap.h
drivers/net/wireless/hostap/hostap_hw.c
drivers/net/wireless/hostap/hostap_ioctl.c
drivers/net/wireless/hostap/hostap_main.c
drivers/net/wireless/hostap/hostap_wlan.h
drivers/net/wireless/strip.c
drivers/s390/net/qeth.h
drivers/s390/net/qeth_main.c
include/linux/etherdevice.h
include/linux/if_ether.h
include/linux/if_shaper.h
include/linux/isdn.h
include/linux/netdevice.h
include/net/ax25.h
include/net/pkt_sched.h
net/802/fc.c
net/802/fddi.c
net/802/hippi.c
net/802/tr.c
net/8021q/vlan.c
net/8021q/vlan.h
net/8021q/vlan_dev.c
net/appletalk/dev.c
net/ax25/ax25_ip.c
net/core/dev.c
net/core/neighbour.c
net/ethernet/eth.c
net/ipv4/arp.c
net/ipv4/ip_gre.c
net/ipv4/ip_output.c
net/ipv6/ndisc.c
net/mac80211/ieee80211.c
net/netrom/nr_dev.c
net/packet/af_packet.c
net/rose/rose_dev.c
net/sched/sch_teql.c

index b31f90082e359f3ac14d5da45bf36a686f3fa6bb..dc9dce22f6a8e2e0248edd20e9910285699db754 100644 (file)
@@ -159,15 +159,16 @@ MODULE_PARM_DESC(max_partial_datagrams,
 
 
 static int ether1394_header(struct sk_buff *skb, struct net_device *dev,
-                           unsigned short type, void *daddr, void *saddr,
-                           unsigned len);
+                           unsigned short type, const void *daddr,
+                           const void *saddr, unsigned len);
 static int ether1394_rebuild_header(struct sk_buff *skb);
 static int ether1394_header_parse(const struct sk_buff *skb,
                                  unsigned char *haddr);
-static int ether1394_header_cache(struct neighbour *neigh, struct hh_cache *hh);
+static int ether1394_header_cache(const struct neighbour *neigh,
+                                 struct hh_cache *hh);
 static void ether1394_header_cache_update(struct hh_cache *hh,
-                                         struct net_device *dev,
-                                         unsigned char *haddr);
+                                         const struct net_device *dev,
+                                         const unsigned char *haddr);
 static int ether1394_tx(struct sk_buff *skb, struct net_device *dev);
 static void ether1394_iso(struct hpsb_iso *iso);
 
@@ -507,6 +508,14 @@ static void ether1394_reset_priv(struct net_device *dev, int set_mtu)
        spin_unlock_irqrestore(&priv->lock, flags);
 }
 
+static const struct header_ops ether1394_header_ops = {
+       .create         = ether1394_header,
+       .rebuild        = ether1394_rebuild_header,
+       .cache          = ether1394_header_cache,
+       .cache_update   = ether1394_header_cache_update,
+       .parse          = ether1394_header_parse,
+};
+
 static void ether1394_init_dev(struct net_device *dev)
 {
        dev->open               = ether1394_open;
@@ -516,11 +525,7 @@ static void ether1394_init_dev(struct net_device *dev)
        dev->tx_timeout         = ether1394_tx_timeout;
        dev->change_mtu         = ether1394_change_mtu;
 
-       dev->hard_header        = ether1394_header;
-       dev->rebuild_header     = ether1394_rebuild_header;
-       dev->hard_header_cache  = ether1394_header_cache;
-       dev->header_cache_update= ether1394_header_cache_update;
-       dev->hard_header_parse  = ether1394_header_parse;
+       dev->header_ops         = &ether1394_header_ops;
 
        SET_ETHTOOL_OPS(dev, &ethtool_ops);
 
@@ -711,8 +716,8 @@ static void ether1394_host_reset(struct hpsb_host *host)
  * saddr=NULL means use device source address
  * daddr=NULL means leave destination address (eg unresolved arp). */
 static int ether1394_header(struct sk_buff *skb, struct net_device *dev,
-                           unsigned short type, void *daddr, void *saddr,
-                           unsigned len)
+                           unsigned short type, const void *daddr,
+                           const void *saddr, unsigned len)
 {
        struct eth1394hdr *eth =
                        (struct eth1394hdr *)skb_push(skb, ETH1394_HLEN);
@@ -759,7 +764,8 @@ static int ether1394_header_parse(const struct sk_buff *skb,
        return ETH1394_ALEN;
 }
 
-static int ether1394_header_cache(struct neighbour *neigh, struct hh_cache *hh)
+static int ether1394_header_cache(const struct neighbour *neigh,
+                                 struct hh_cache *hh)
 {
        unsigned short type = hh->hh_type;
        struct net_device *dev = neigh->dev;
@@ -778,8 +784,8 @@ static int ether1394_header_cache(struct neighbour *neigh, struct hh_cache *hh)
 
 /* Called by Address Resolution module to notify changes in address. */
 static void ether1394_header_cache_update(struct hh_cache *hh,
-                                         struct net_device *dev,
-                                         unsigned char * haddr)
+                                         const struct net_device *dev,
+                                         const unsigned char * haddr)
 {
        memcpy((u8 *)hh->hh_data + 16 - ETH1394_HLEN, haddr, dev->addr_len);
 }
@@ -899,8 +905,8 @@ static u16 ether1394_parse_encap(struct sk_buff *skb, struct net_device *dev,
        }
 
        /* Now add the ethernet header. */
-       if (dev->hard_header(skb, dev, ntohs(ether_type), &dest_hw, NULL,
-                            skb->len) >= 0)
+       if (dev_hard_header(skb, dev, ntohs(ether_type), &dest_hw, NULL,
+                           skb->len) >= 0)
                ret = ether1394_type_trans(skb, dev);
 
        return ret;
index b1c3d6cd8ebae1127058517aefe3a469ff4061a9..2bd76ef57154a0b9cd1115f9c1490f5f5b46437d 100644 (file)
@@ -780,7 +780,7 @@ static void ipoib_timeout(struct net_device *dev)
 static int ipoib_hard_header(struct sk_buff *skb,
                             struct net_device *dev,
                             unsigned short type,
-                            void *daddr, void *saddr, unsigned len)
+                            const void *daddr, const void *saddr, unsigned len)
 {
        struct ipoib_header *header;
 
@@ -940,6 +940,10 @@ void ipoib_dev_cleanup(struct net_device *dev)
        priv->tx_ring = NULL;
 }
 
+static const struct header_ops ipoib_header_ops = {
+       .create = ipoib_hard_header,
+};
+
 static void ipoib_setup(struct net_device *dev)
 {
        struct ipoib_dev_priv *priv = netdev_priv(dev);
@@ -950,7 +954,7 @@ static void ipoib_setup(struct net_device *dev)
        dev->hard_start_xmit     = ipoib_start_xmit;
        dev->get_stats           = ipoib_get_stats;
        dev->tx_timeout          = ipoib_timeout;
-       dev->hard_header         = ipoib_hard_header;
+       dev->header_ops          = &ipoib_header_ops;
        dev->set_multicast_list  = ipoib_set_mcast_list;
        dev->neigh_setup         = ipoib_neigh_setup_dev;
 
index aa83277aba74c78c011e3b071ba5df7c067b165d..54546604656d0b0378a4f8a4b9a01246191825f4 100644 (file)
@@ -1873,54 +1873,14 @@ isdn_net_rcv_skb(int idx, struct sk_buff *skb)
        return 0;
 }
 
-static int
-my_eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
-             void *daddr, void *saddr, unsigned len)
-{
-       struct ethhdr *eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
-
-       /*
-        * Set the protocol type. For a packet of type ETH_P_802_3 we
-        * put the length here instead. It is up to the 802.2 layer to
-        * carry protocol information.
-        */
-
-       if (type != ETH_P_802_3)
-               eth->h_proto = htons(type);
-       else
-               eth->h_proto = htons(len);
-
-       /*
-        * Set the source hardware address.
-        */
-       if (saddr)
-               memcpy(eth->h_source, saddr, dev->addr_len);
-       else
-               memcpy(eth->h_source, dev->dev_addr, dev->addr_len);
-
-       /*
-        * Anyway, the loopback-device should never use this function...
-        */
-
-       if (dev->flags & (IFF_LOOPBACK | IFF_NOARP)) {
-               memset(eth->h_dest, 0, dev->addr_len);
-               return ETH_HLEN /*(dev->hard_header_len)*/;
-       }
-       if (daddr) {
-               memcpy(eth->h_dest, daddr, dev->addr_len);
-               return ETH_HLEN /*dev->hard_header_len*/;
-       }
-       return -ETH_HLEN /*dev->hard_header_len*/;
-}
-
 /*
  *  build an header
  *  depends on encaps that is being used.
  */
 
-static int
-isdn_net_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
-               void *daddr, void *saddr, unsigned plen)
+static int isdn_net_header(struct sk_buff *skb, struct net_device *dev,
+                          unsigned short type,
+                          const void *daddr, const void *saddr, unsigned plen)
 {
        isdn_net_local *lp = dev->priv;
        unsigned char *p;
@@ -1928,7 +1888,7 @@ isdn_net_header(struct sk_buff *skb, struct net_device *dev, unsigned short type
 
        switch (lp->p_encap) {
                case ISDN_NET_ENCAP_ETHER:
-                       len = my_eth_header(skb, dev, type, daddr, saddr, plen);
+                       len = eth_header(skb, dev, type, daddr, saddr, plen);
                        break;
 #ifdef CONFIG_ISDN_PPP
                case ISDN_NET_ENCAP_SYNCPPP:
@@ -2005,6 +1965,32 @@ isdn_net_rebuild_header(struct sk_buff *skb)
        return ret;
 }
 
+static int isdn_header_cache(const struct neighbour *neigh, struct hh_cache *hh)
+{
+       const struct net_device *dev = neigh->dev;
+       isdn_net_local *lp = dev->priv;
+
+       if (lp->p_encap == ISDN_NET_ENCAP_ETHER)
+               return eth_header_cache(neigh, hh);
+       return -1;
+}
+
+static void isdn_header_cache_update(struct hh_cache *hh,
+                                    const struct net_device *dev,
+                                    const unsigned char *haddr)
+{
+       isdn_net_local *lp = dev->priv;
+       if (lp->p_encap == ISDN_NET_ENCAP_ETHER)
+               return eth_header_cache_update(hh, dev, haddr);
+}
+
+static const struct header_ops isdn_header_ops = {
+       .create = isdn_net_header,
+       .rebuild = isdn_net_rebuild_header,
+       .cache = isdn_header_cache,
+       .cache_update = isdn_header_cache_update,
+};
+
 /*
  * Interface-setup. (just after registering a new interface)
  */
@@ -2012,18 +1998,12 @@ static int
 isdn_net_init(struct net_device *ndev)
 {
        ushort max_hlhdr_len = 0;
-       isdn_net_local *lp = (isdn_net_local *) ndev->priv;
-       int drvidx, i;
+       int drvidx;
 
        ether_setup(ndev);
-       lp->org_hhc = ndev->hard_header_cache;
-       lp->org_hcu = ndev->header_cache_update;
+       ndev->header_ops = NULL;
 
        /* Setup the generic properties */
-
-       ndev->hard_header = NULL;
-       ndev->hard_header_cache = NULL;
-       ndev->header_cache_update = NULL;
        ndev->mtu = 1500;
        ndev->flags = IFF_NOARP|IFF_POINTOPOINT;
        ndev->type = ARPHRD_ETHER;
@@ -2032,9 +2012,6 @@ isdn_net_init(struct net_device *ndev)
        /* for clients with MPPP maybe higher values better */
        ndev->tx_queue_len = 30;
 
-       for (i = 0; i < ETH_ALEN; i++)
-               ndev->broadcast[i] = 0xff;
-
        /* The ISDN-specific entries in the device structure. */
        ndev->open = &isdn_net_open;
        ndev->hard_start_xmit = &isdn_net_start_xmit;
@@ -2052,7 +2029,6 @@ isdn_net_init(struct net_device *ndev)
        ndev->hard_header_len = ETH_HLEN + max_hlhdr_len;
        ndev->stop = &isdn_net_close;
        ndev->get_stats = &isdn_net_get_stats;
-       ndev->rebuild_header = &isdn_net_rebuild_header;
        ndev->do_ioctl = NULL;
        return 0;
 }
@@ -2861,21 +2837,14 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg)
                }
                if (cfg->p_encap != lp->p_encap) {
                        if (cfg->p_encap == ISDN_NET_ENCAP_RAWIP) {
-                               p->dev.hard_header = NULL;
-                               p->dev.hard_header_cache = NULL;
-                               p->dev.header_cache_update = NULL;
+                               p->dev.header_ops = NULL;
                                p->dev.flags = IFF_NOARP|IFF_POINTOPOINT;
                        } else {
-                               p->dev.hard_header = isdn_net_header;
-                               if (cfg->p_encap == ISDN_NET_ENCAP_ETHER) {
-                                       p->dev.hard_header_cache = lp->org_hhc;
-                                       p->dev.header_cache_update = lp->org_hcu;
+                               p->dev.header_ops = &isdn_header_ops;
+                               if (cfg->p_encap == ISDN_NET_ENCAP_ETHER)
                                        p->dev.flags = IFF_BROADCAST | IFF_MULTICAST;
-                               } else {
-                                       p->dev.hard_header_cache = NULL;
-                                       p->dev.header_cache_update = NULL;
+                               else
                                        p->dev.flags = IFF_NOARP|IFF_POINTOPOINT;
-                               }
                        }
                }
                lp->p_encap = cfg->p_encap;
@@ -3127,8 +3096,6 @@ isdn_net_realrm(isdn_net_dev * p, isdn_net_dev * q)
                        ((isdn_net_local *) (p->local->master->priv))->slave = p->local->slave;
        } else {
                /* Unregister only if it's a master-device */
-               p->dev.hard_header_cache = p->local->org_hhc;
-               p->dev.header_cache_update = p->local->org_hcu;
                unregister_netdev(&p->dev);
        }
        /* Unlink device from chain */
index bdd797071cb0e6d4d3d56be1f9acb957792620d5..06800e5a0770185f25023e6188fe88e5e86dda45 100644 (file)
@@ -1225,10 +1225,17 @@ static struct net_device_stats * dvb_net_get_stats(struct net_device *dev)
        return &((struct dvb_net_priv*) dev->priv)->stats;
 }
 
+static const struct header_ops dvb_header_ops = {
+       .create         = eth_header,
+       .parse          = eth_header_parse,
+       .rebuild        = eth_rebuild_header,
+};
+
 static void dvb_net_setup(struct net_device *dev)
 {
        ether_setup(dev);
 
+       dev->header_ops         = &dvb_header_ops;
        dev->open               = dvb_net_open;
        dev->stop               = dvb_net_stop;
        dev->hard_start_xmit    = dvb_net_tx;
@@ -1237,7 +1244,7 @@ static void dvb_net_setup(struct net_device *dev)
        dev->set_mac_address    = dvb_net_set_mac;
        dev->mtu                = 4096;
        dev->mc_count           = 0;
-       dev->hard_header_cache  = NULL;
+
        dev->flags |= IFF_NOARP;
 }
 
index c4b560d42a67a0dac5e8eeb6713edc09b0e51a43..92c3a4cf0bb18d15c83a3ce5f7206a34172514d1 100644 (file)
@@ -194,10 +194,6 @@ static void cops_timeout(struct net_device *dev);
 static void cops_rx (struct net_device *dev);
 static int  cops_send_packet (struct sk_buff *skb, struct net_device *dev);
 static void set_multicast_list (struct net_device *dev);
-static int  cops_hard_header (struct sk_buff *skb, struct net_device *dev,
-                             unsigned short type, void *daddr, void *saddr, 
-                             unsigned len);
-
 static int  cops_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
 static int  cops_close (struct net_device *dev);
 static struct net_device_stats *cops_get_stats (struct net_device *dev);
@@ -331,7 +327,6 @@ static int __init cops_probe1(struct net_device *dev, int ioaddr)
        dev->base_addr = ioaddr;
 
         lp = netdev_priv(dev);
-        memset(lp, 0, sizeof(struct cops_local));
         spin_lock_init(&lp->lock);
 
        /* Copy local board variable to lp struct. */
@@ -340,7 +335,7 @@ static int __init cops_probe1(struct net_device *dev, int ioaddr)
        dev->hard_start_xmit    = cops_send_packet;
        dev->tx_timeout         = cops_timeout;
        dev->watchdog_timeo     = HZ * 2;
-       dev->hard_header        = cops_hard_header;
+
         dev->get_stats          = cops_get_stats;
        dev->open               = cops_open;
         dev->stop               = cops_close;
@@ -944,19 +939,6 @@ static void set_multicast_list(struct net_device *dev)
                printk("%s: set_multicast_list executed\n", dev->name);
 }
 
-/*
- *      Another Dummy function to keep the Appletalk layer happy.
- */
-static int cops_hard_header(struct sk_buff *skb, struct net_device *dev,
-                           unsigned short type, void *daddr, void *saddr, 
-                           unsigned len)
-{
-        if(cops_debug >= 3)
-                printk("%s: cops_hard_header executed. Wow!\n", dev->name);
-        return 0;
-}
-
 /*
  *      System ioctls for the COPS LocalTalk card.
  */
index cb4744e56905d59e84695273af2181977319b6cb..6ab2c2d4d673de32baf44307a32a0d5baf00183b 100644 (file)
@@ -870,15 +870,6 @@ static void set_multicast_list(struct net_device *dev)
        /* Actually netatalk needs fixing! */
 }
 
-static int ltpc_hard_header (struct sk_buff *skb, struct net_device *dev, 
-       unsigned short type, void *daddr, void *saddr, unsigned len)
-{
-       if(debug & DEBUG_VERBOSE)
-               printk("ltpc_hard_header called for device %s\n",
-                       dev->name);
-       return 0;
-}
-
 static int ltpc_poll_counter;
 
 static void ltpc_poll(unsigned long l)
@@ -1141,7 +1132,6 @@ struct net_device * __init ltpc_probe(void)
 
        /* Fill in the fields of the device structure with ethernet-generic values. */
        dev->hard_start_xmit = ltpc_xmit;
-       dev->hard_header = ltpc_hard_header;
        dev->get_stats = ltpc_get_stats;
 
        /* add the ltpc-specific things */
index 681e20b8466f7cc9e45bf549817817cf6dcfd4ce..c59c8067de991989498bceb5b9f0dbc9a60c2e03 100644 (file)
@@ -102,8 +102,8 @@ static int arcnet_close(struct net_device *dev);
 static int arcnet_send_packet(struct sk_buff *skb, struct net_device *dev);
 static void arcnet_timeout(struct net_device *dev);
 static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
-                        unsigned short type, void *daddr, void *saddr,
-                        unsigned len);
+                        unsigned short type, const void *daddr,
+                        const void *saddr, unsigned len);
 static int arcnet_rebuild_header(struct sk_buff *skb);
 static struct net_device_stats *arcnet_get_stats(struct net_device *dev);
 static int go_tx(struct net_device *dev);
@@ -317,11 +317,17 @@ static int choose_mtu(void)
        return mtu == 65535 ? XMTU : mtu;
 }
 
+static const struct header_ops arcnet_header_ops = {
+       .create = arcnet_header,
+       .rebuild = arcnet_rebuild_header,
+};
+
 
 /* Setup a struct device for ARCnet. */
 static void arcdev_setup(struct net_device *dev)
 {
        dev->type = ARPHRD_ARCNET;
+       dev->header_ops = &arcnet_header_ops;
        dev->hard_header_len = sizeof(struct archdr);
        dev->mtu = choose_mtu();
 
@@ -342,8 +348,6 @@ static void arcdev_setup(struct net_device *dev)
        dev->hard_start_xmit = arcnet_send_packet;
        dev->tx_timeout = arcnet_timeout;
        dev->get_stats = arcnet_get_stats;
-       dev->hard_header = arcnet_header;
-       dev->rebuild_header = arcnet_rebuild_header;
 }
 
 struct net_device *alloc_arcdev(char *name)
@@ -488,10 +492,10 @@ static int arcnet_close(struct net_device *dev)
 
 
 static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
-                        unsigned short type, void *daddr, void *saddr,
-                        unsigned len)
+                        unsigned short type, const void *daddr,
+                        const void *saddr, unsigned len)
 {
-       struct arcnet_local *lp = dev->priv;
+       const struct arcnet_local *lp = netdev_priv(dev);
        uint8_t _daddr, proto_num;
        struct ArcProto *proto;
 
index 0a847326a5e4128833e429b7b81f4f8bf5fdace7..ecd156def0398b24864313843b712caa186fb9ca 100644 (file)
@@ -288,7 +288,8 @@ static int sp_close(struct net_device *dev)
 
 /* Return the frame type ID */
 static int sp_header(struct sk_buff *skb, struct net_device *dev,
-       unsigned short type, void *daddr, void *saddr, unsigned len)
+                    unsigned short type, const void *daddr,
+                    const void *saddr, unsigned len)
 {
 #ifdef CONFIG_INET
        if (type != htons(ETH_P_AX25))
@@ -323,6 +324,11 @@ static int sp_rebuild_header(struct sk_buff *skb)
 #endif
 }
 
+static const struct header_ops sp_header_ops = {
+       .create         = sp_header,
+       .rebuild        = sp_rebuild_header,
+};
+
 static void sp_setup(struct net_device *dev)
 {
        /* Finish setting up the DEVICE info. */
@@ -331,14 +337,15 @@ static void sp_setup(struct net_device *dev)
        dev->open               = sp_open_dev;
        dev->destructor         = free_netdev;
        dev->stop               = sp_close;
-       dev->hard_header        = sp_header;
+
        dev->get_stats          = sp_get_stats;
        dev->set_mac_address    = sp_set_mac_address;
        dev->hard_header_len    = AX25_MAX_HEADER_LEN;
+       dev->header_ops         = &sp_header_ops;
+
        dev->addr_len           = AX25_ADDR_LEN;
        dev->type               = ARPHRD_AX25;
        dev->tx_queue_len       = 10;
-       dev->rebuild_header     = sp_rebuild_header;
        dev->tx_timeout         = NULL;
 
        /* Only activated in AX.25 mode */
index 355c6cf3d11212870f16628ebd0e7dde489354da..1a5a75acf73e4a0609bf6ecf52515496318e47f8 100644 (file)
@@ -1159,8 +1159,7 @@ static void baycom_probe(struct net_device *dev)
        /* Fill in the fields of the device structure */
        bc->skb = NULL;
        
-       dev->hard_header = ax25_hard_header;
-       dev->rebuild_header = ax25_rebuild_header;
+       dev->header_ops = &ax25_header_ops;
        dev->set_mac_address = baycom_set_mac_address;
        
        dev->type = ARPHRD_AX25;           /* AF_AX25 device */
index 4bff23e3b970c71bf4e8f840aa22861b76e5ca27..5ddf8b0c34f9286fe7fe61060088d4327fe30481 100644 (file)
@@ -483,8 +483,7 @@ static void bpq_setup(struct net_device *dev)
        dev->flags      = 0;
 
 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
-       dev->hard_header     = ax25_hard_header;
-       dev->rebuild_header  = ax25_rebuild_header;
+       dev->header_ops      = &ax25_header_ops;
 #endif
 
        dev->type            = ARPHRD_AX25;
index 205f09672492b4f4ec42236a264779717cc6297d..bc02e469480401274cee6e7f771f9ab62afe3c0e 100644 (file)
@@ -581,8 +581,7 @@ static int __init setup_adapter(int card_base, int type, int n)
                dev->do_ioctl = scc_ioctl;
                dev->hard_start_xmit = scc_send_packet;
                dev->get_stats = scc_get_stats;
-               dev->hard_header = ax25_hard_header;
-               dev->rebuild_header = ax25_rebuild_header;
+               dev->header_ops = &ax25_header_ops;
                dev->set_mac_address = scc_set_mac_address;
        }
        if (register_netdev(info->dev[0])) {
index b33adc6a340b055ad8b1a2076331f5697f83a517..ae9629fa6882bb1dd2181e804b9a881a6c49c962 100644 (file)
@@ -682,8 +682,7 @@ static void hdlcdrv_setup(struct net_device *dev)
 
        s->skb = NULL;
        
-       dev->hard_header = ax25_hard_header;
-       dev->rebuild_header = ax25_rebuild_header;
+       dev->header_ops = &ax25_header_ops;
        dev->set_mac_address = hdlcdrv_set_mac_address;
        
        dev->type = ARPHRD_AX25;           /* AF_AX25 device */
index d08fbc3966481fd40c6d790efbf6b455abc2e56a..9e43c47691caa4c9d12a6015a1668277424c3b25 100644 (file)
@@ -578,8 +578,9 @@ static int ax_open_dev(struct net_device *dev)
 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
 
 /* Return the frame type ID */
-static int ax_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
-         void *daddr, void *saddr, unsigned len)
+static int ax_header(struct sk_buff *skb, struct net_device *dev,
+                    unsigned short type, const void *daddr,
+                    const void *saddr, unsigned len)
 {
 #ifdef CONFIG_INET
        if (type != htons(ETH_P_AX25))
@@ -670,6 +671,11 @@ static struct net_device_stats *ax_get_stats(struct net_device *dev)
        return &ax->stats;
 }
 
+static const struct header_ops ax_header_ops = {
+       .create    = ax_header,
+       .rebuild   = ax_rebuild_header,
+};
+
 static void ax_setup(struct net_device *dev)
 {
        /* Finish setting up the DEVICE info. */
@@ -683,8 +689,8 @@ static void ax_setup(struct net_device *dev)
        dev->addr_len        = 0;
        dev->type            = ARPHRD_AX25;
        dev->tx_queue_len    = 10;
-       dev->hard_header     = ax_header;
-       dev->rebuild_header  = ax_rebuild_header;
+       dev->header_ops      = &ax_header_ops;
+
 
        memcpy(dev->broadcast, &ax25_bcast, AX25_ADDR_LEN);
        memcpy(dev->dev_addr,  &ax25_defaddr,  AX25_ADDR_LEN);
index 39b3b82aa4a495fc5e5b4cf3bafad7bbc6a181fd..353d13e543ce12228428b90d14df93f903d76b45 100644 (file)
@@ -1551,8 +1551,8 @@ static void scc_net_setup(struct net_device *dev)
        dev->stop            = scc_net_close;
 
        dev->hard_start_xmit = scc_net_tx;
-       dev->hard_header     = ax25_hard_header;
-       dev->rebuild_header  = ax25_rebuild_header;
+       dev->header_ops      = &ax25_header_ops;
+
        dev->set_mac_address = scc_net_set_mac_address;
        dev->get_stats       = scc_net_get_stats;
        dev->do_ioctl        = scc_net_ioctl;
index 401724ddafcd83fd61d048a3163361946529ff20..1c942862a3f4944710de74c546cba66943b8b81a 100644 (file)
@@ -1097,8 +1097,7 @@ static void yam_setup(struct net_device *dev)
 
        skb_queue_head_init(&yp->send_queue);
 
-       dev->hard_header = ax25_hard_header;
-       dev->rebuild_header = ax25_rebuild_header;
+       dev->header_ops = &ax25_header_ops;
 
        dev->set_mac_address = yam_set_mac_address;
 
index f11120b7a3b2e283a9f5bdd5a44c452a045fbf64..b6d4ae3ad506a387dbd152591e3f10044905c2cb 100644 (file)
@@ -221,22 +221,17 @@ static void loopback_dev_free(struct net_device *dev)
 }
 
 /*
- * The loopback device is special. There is only one instance and
- * it is statically allocated. Don't do this for other devices.
+ * The loopback device is special. There is only one instance.
  */
 static void loopback_setup(struct net_device *dev)
 {
        dev->get_stats          = &get_stats;
        dev->mtu                = (16 * 1024) + 20 + 20 + 12;
        dev->hard_start_xmit    = loopback_xmit;
-       dev->hard_header        = eth_header;
-       dev->hard_header_cache  = eth_header_cache;
-       dev->header_cache_update = eth_header_cache_update;
        dev->hard_header_len    = ETH_HLEN;     /* 14   */
        dev->addr_len           = ETH_ALEN;     /* 6    */
        dev->tx_queue_len       = 0;
        dev->type               = ARPHRD_LOOPBACK;      /* 0x0001*/
-       dev->rebuild_header     = eth_rebuild_header;
        dev->flags              = IFF_LOOPBACK;
        dev->features           = NETIF_F_SG | NETIF_F_FRAGLIST
 #ifdef LOOPBACK_TSO
@@ -247,6 +242,7 @@ static void loopback_setup(struct net_device *dev)
                | NETIF_F_LLTX
                | NETIF_F_NETNS_LOCAL,
        dev->ethtool_ops        = &loopback_ethtool_ops;
+       dev->header_ops         = &eth_header_ops;
        dev->init = loopback_dev_init;
        dev->destructor = loopback_dev_free;
 }
index a22087ca968d869dd334bca799a84660cccc24a9..b7c81c874f7a0a15e4bd65281aa9ceeb1e83b0cf 100644 (file)
@@ -164,8 +164,8 @@ static int macvlan_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 }
 
 static int macvlan_hard_header(struct sk_buff *skb, struct net_device *dev,
-                              unsigned short type, void *daddr, void *saddr,
-                              unsigned len)
+                              unsigned short type, const void *daddr,
+                              const void *saddr, unsigned len)
 {
        const struct macvlan_dev *vlan = netdev_priv(dev);
        struct net_device *lowerdev = vlan->lowerdev;
@@ -174,6 +174,15 @@ static int macvlan_hard_header(struct sk_buff *skb, struct net_device *dev,
                               saddr ? : dev->dev_addr, len);
 }
 
+static const struct header_ops macvlan_hard_header_ops = {
+       .create         = macvlan_hard_header,
+       .rebuild        = eth_rebuild_header,
+       .parse          = eth_header_parse,
+       .rebuild        = eth_rebuild_header,
+       .cache          = eth_header_cache,
+       .cache_update   = eth_header_cache_update,
+};
+
 static int macvlan_open(struct net_device *dev)
 {
        struct macvlan_dev *vlan = netdev_priv(dev);
@@ -295,9 +304,9 @@ static void macvlan_setup(struct net_device *dev)
        dev->change_mtu         = macvlan_change_mtu;
        dev->change_rx_flags    = macvlan_change_rx_flags;
        dev->set_multicast_list = macvlan_set_multicast_list;
-       dev->hard_header        = macvlan_hard_header;
        dev->hard_start_xmit    = macvlan_hard_start_xmit;
        dev->destructor         = free_netdev;
+       dev->header_ops         = &macvlan_hard_header_ops,
        dev->ethtool_ops        = &macvlan_ethtool_ops;
        dev->tx_queue_len       = 0;
 }
index d68ee51c095f423aadbd9c5e9c43b51f7380c4ad..8d29319cc5cb39b88b3f13a37cb017bf28b595b2 100644 (file)
@@ -676,8 +676,9 @@ static int myri_start_xmit(struct sk_buff *skb, struct net_device *dev)
  * saddr=NULL  means use device source address
  * daddr=NULL  means leave destination address (eg unresolved arp)
  */
-static int myri_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
-                      void *daddr, void *saddr, unsigned len)
+static int myri_header(struct sk_buff *skb, struct net_device *dev,
+                      unsigned short type, const void *daddr,
+                      const void *saddr, unsigned len)
 {
        struct ethhdr *eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
        unsigned char *pad = (unsigned char *) skb_push(skb, MYRI_PAD_LEN);
@@ -759,18 +760,18 @@ static int myri_rebuild_header(struct sk_buff *skb)
        return 0;
 }
 
-int myri_header_cache(struct neighbour *neigh, struct hh_cache *hh)
+static int myri_header_cache(const struct neighbour *neigh, struct hh_cache *hh)
 {
        unsigned short type = hh->hh_type;
        unsigned char *pad;
        struct ethhdr *eth;
-       struct net_device *dev = neigh->dev;
+       const struct net_device *dev = neigh->dev;
 
        pad = ((unsigned char *) hh->hh_data) +
                HH_DATA_OFF(sizeof(*eth) + MYRI_PAD_LEN);
        eth = (struct ethhdr *) (pad + MYRI_PAD_LEN);
 
-       if (type == __constant_htons(ETH_P_802_3))
+       if (type == htons(ETH_P_802_3))
                return -1;
 
        /* Refill MyriNet padding identifiers, this is just being anal. */
@@ -786,7 +787,9 @@ int myri_header_cache(struct neighbour *neigh, struct hh_cache *hh)
 
 
 /* Called by Address Resolution module to notify changes in address. */
-void myri_header_cache_update(struct hh_cache *hh, struct net_device *dev, unsigned char * haddr)
+void myri_header_cache_update(struct hh_cache *hh,
+                             const struct net_device *dev,
+                             const unsigned char * haddr)
 {
        memcpy(((u8*)hh->hh_data) + HH_DATA_OFF(sizeof(struct ethhdr)),
               haddr, dev->addr_len);
@@ -881,6 +884,13 @@ static void dump_eeprom(struct myri_eth *mp)
 }
 #endif
 
+static const struct header_ops myri_header_ops = {
+       .create         = myri_header,
+       .rebuild        = myri_rebuild_header,
+       .cache          = myri_header_cache,
+       .cache_update   = myri_header_cache_update,
+};
+
 static int __devinit myri_ether_init(struct sbus_dev *sdev)
 {
        static int num;
@@ -1065,11 +1075,9 @@ static int __devinit myri_ether_init(struct sbus_dev *sdev)
 
        dev->mtu                = MYRINET_MTU;
        dev->change_mtu         = myri_change_mtu;
-       dev->hard_header        = myri_header;
-       dev->rebuild_header     = myri_rebuild_header;
+       dev->header_ops         = &myri_header_ops;
+
        dev->hard_header_len    = (ETH_HLEN + MYRI_PAD_LEN);
-       dev->hard_header_cache  = myri_header_cache;
-       dev->header_cache_update= myri_header_cache_update;
 
        /* Load code onto the LANai. */
        DET(("Loading LANAI firmware\n"));
index c17d9ac9ff30d9c6b9fd1c5828f039bf42bd7bc7..b5e9981d10605a57d53817fa8cfb3ee7b257146e 100644 (file)
@@ -148,9 +148,9 @@ static void plip_interrupt(int irq, void *dev_id);
 /* Functions for DEV methods */
 static int plip_tx_packet(struct sk_buff *skb, struct net_device *dev);
 static int plip_hard_header(struct sk_buff *skb, struct net_device *dev,
-                            unsigned short type, void *daddr,
-                            void *saddr, unsigned len);
-static int plip_hard_header_cache(struct neighbour *neigh,
+                            unsigned short type, const void *daddr,
+                           const void *saddr, unsigned len);
+static int plip_hard_header_cache(const struct neighbour *neigh,
                                   struct hh_cache *hh);
 static int plip_open(struct net_device *dev);
 static int plip_close(struct net_device *dev);
@@ -219,11 +219,6 @@ struct net_local {
        int is_deferred;
        int port_owner;
        int should_relinquish;
-       int (*orig_hard_header)(struct sk_buff *skb, struct net_device *dev,
-                               unsigned short type, void *daddr,
-                               void *saddr, unsigned len);
-       int (*orig_hard_header_cache)(struct neighbour *neigh,
-                                     struct hh_cache *hh);
        spinlock_t lock;
        atomic_t kill_timer;
        struct semaphore killed_timer_sem;
@@ -265,6 +260,11 @@ static inline unsigned char read_status (struct net_device *dev)
        return port->ops->read_status (port);
 }
 
+static const struct header_ops plip_header_ops = {
+       .create = plip_hard_header,
+       .cache  = plip_hard_header_cache,
+};
+
 /* Entry point of PLIP driver.
    Probe the hardware, and register/initialize the driver.
 
@@ -284,17 +284,12 @@ plip_init_netdev(struct net_device *dev)
        dev->open                = plip_open;
        dev->stop                = plip_close;
        dev->do_ioctl            = plip_ioctl;
-       dev->header_cache_update = NULL;
+
        dev->tx_queue_len        = 10;
        dev->flags               = IFF_POINTOPOINT|IFF_NOARP;
        memset(dev->dev_addr, 0xfc, ETH_ALEN);
 
-       /* Set the private structure */
-       nl->orig_hard_header    = dev->hard_header;
-       dev->hard_header        = plip_hard_header;
-
-       nl->orig_hard_header_cache = dev->hard_header_cache;
-       dev->hard_header_cache     = plip_hard_header_cache;
+       dev->header_ops          = &plip_header_ops;
 
 
        nl->port_owner = 0;
@@ -993,14 +988,14 @@ plip_tx_packet(struct sk_buff *skb, struct net_device *dev)
 }
 
 static void
-plip_rewrite_address(struct net_device *dev, struct ethhdr *eth)
+plip_rewrite_address(const struct net_device *dev, struct ethhdr *eth)
 {
-       struct in_device *in_dev;
+       const struct in_device *in_dev = dev->ip_ptr;
 
-       if ((in_dev=dev->ip_ptr) != NULL) {
+       if (in_dev) {
                /* Any address will do - we take the first */
-               struct in_ifaddr *ifa=in_dev->ifa_list;
-               if (ifa != NULL) {
+               const struct in_ifaddr *ifa = in_dev->ifa_list;
+               if (ifa) {
                        memcpy(eth->h_source, dev->dev_addr, 6);
                        memset(eth->h_dest, 0xfc, 2);
                        memcpy(eth->h_dest+2, &ifa->ifa_address, 4);
@@ -1010,26 +1005,25 @@ plip_rewrite_address(struct net_device *dev, struct ethhdr *eth)
 
 static int
 plip_hard_header(struct sk_buff *skb, struct net_device *dev,
-                 unsigned short type, void *daddr,
-                void *saddr, unsigned len)
+                unsigned short type, const void *daddr,
+                const void *saddr, unsigned len)
 {
-       struct net_local *nl = netdev_priv(dev);
        int ret;
 
-       if ((ret = nl->orig_hard_header(skb, dev, type, daddr, saddr, len)) >= 0)
+       ret = eth_header(skb, dev, type, daddr, saddr, len);
+       if (ret >= 0)
                plip_rewrite_address (dev, (struct ethhdr *)skb->data);
 
        return ret;
 }
 
-int plip_hard_header_cache(struct neighbour *neigh,
+int plip_hard_header_cache(const struct neighbour *neigh,
                            struct hh_cache *hh)
 {
-       struct net_local *nl = neigh->dev->priv;
        int ret;
 
-       if ((ret = nl->orig_hard_header_cache(neigh, hh)) == 0)
-       {
+       ret = eth_header_cache(neigh, hh);
+       if (ret == 0) {
                struct ethhdr *eth;
 
                eth = (struct ethhdr*)(((u8*)hh->hh_data) +
index 315feba7dacc0f7ca2efe9243d72a27e48f32aef..228f650250f6f0b6ebeacc2f63dd3f6addcc1d58 100644 (file)
@@ -331,15 +331,16 @@ static int shaper_close(struct net_device *dev)
  */
 
 static int shaper_header(struct sk_buff *skb, struct net_device *dev,
-       unsigned short type, void *daddr, void *saddr, unsigned len)
+                        unsigned short type,
+                        const void *daddr, const void *saddr, unsigned len)
 {
        struct shaper *sh=dev->priv;
        int v;
        if(sh_debug)
                printk("Shaper header\n");
-       skb->dev=sh->dev;
-       v=sh->hard_header(skb,sh->dev,type,daddr,saddr,len);
-       skb->dev=dev;
+       skb->dev = sh->dev;
+       v = dev_hard_header(skb, sh->dev, type, daddr, saddr, len);
+       skb->dev = dev;
        return v;
 }
 
@@ -351,7 +352,7 @@ static int shaper_rebuild_header(struct sk_buff *skb)
        if(sh_debug)
                printk("Shaper rebuild header\n");
        skb->dev=sh->dev;
-       v=sh->rebuild_header(skb);
+       v = sh->dev->header_ops->rebuild(skb);
        skb->dev=dev;
        return v;
 }
@@ -415,51 +416,17 @@ static int shaper_neigh_setup_dev(struct net_device *dev, struct neigh_parms *p)
 
 #endif
 
+static const struct header_ops shaper_ops = {
+       .create  = shaper_header,
+       .rebuild = shaper_rebuild_header,
+};
+
 static int shaper_attach(struct net_device *shdev, struct shaper *sh, struct net_device *dev)
 {
        sh->dev = dev;
-       sh->hard_start_xmit=dev->hard_start_xmit;
        sh->get_stats=dev->get_stats;
-       if(dev->hard_header)
-       {
-               sh->hard_header=dev->hard_header;
-               shdev->hard_header = shaper_header;
-       }
-       else
-               shdev->hard_header = NULL;
 
-       if(dev->rebuild_header)
-       {
-               sh->rebuild_header      = dev->rebuild_header;
-               shdev->rebuild_header   = shaper_rebuild_header;
-       }
-       else
-               shdev->rebuild_header   = NULL;
-
-#if 0
-       if(dev->hard_header_cache)
-       {
-               sh->hard_header_cache   = dev->hard_header_cache;
-               shdev->hard_header_cache= shaper_cache;
-       }
-       else
-       {
-               shdev->hard_header_cache= NULL;
-       }
-
-       if(dev->header_cache_update)
-       {
-               sh->header_cache_update = dev->header_cache_update;
-               shdev->header_cache_update = shaper_cache_update;
-       }
-       else
-               shdev->header_cache_update= NULL;
-#else
-       shdev->header_cache_update = NULL;
-       shdev->hard_header_cache = NULL;
-#endif
        shdev->neigh_setup = shaper_neigh_setup_dev;
-
        shdev->hard_header_len=dev->hard_header_len;
        shdev->type=dev->type;
        shdev->addr_len=dev->addr_len;
@@ -542,12 +509,6 @@ static void __init shaper_setup(struct net_device *dev)
         *      Handlers for when we attach to a device.
         */
 
-       dev->hard_header        = shaper_header;
-       dev->rebuild_header     = shaper_rebuild_header;
-#if 0
-       dev->hard_header_cache  = shaper_cache;
-       dev->header_cache_update= shaper_cache_update;
-#endif
        dev->neigh_setup        = shaper_neigh_setup_dev;
        dev->do_ioctl           = shaper_ioctl;
        dev->hard_header_len    = 0;
index ca508708229d765f75f110e2e046e00417525368..7cf9b9f35dee4defb5277648ff4f3f50426c5d07 100644 (file)
@@ -260,7 +260,6 @@ static int skfp_init_one(struct pci_dev *pdev,
        dev->set_multicast_list = &skfp_ctl_set_multicast_list;
        dev->set_mac_address = &skfp_ctl_set_mac_address;
        dev->do_ioctl = &skfp_ioctl;
-       dev->header_cache_update = NULL;        /* not supported */
 
        SET_NETDEV_DEV(dev, &pdev->dev);
 
index 46e053106d4d88c221823605b9b155eeb7081912..8a1778cf98d1cc0bc7b282e2d43610f78e9c8104 100644 (file)
@@ -131,14 +131,15 @@ static int cycx_wan_update(struct wan_device *wandev),
           cycx_wan_del_if(struct wan_device *wandev, struct net_device *dev);
 
 /* Network device interface */
-static int cycx_netdevice_init(struct net_device *dev),
-          cycx_netdevice_open(struct net_device *dev),
-          cycx_netdevice_stop(struct net_device *dev),
-          cycx_netdevice_hard_header(struct sk_buff *skb,
-                                    struct net_device *dev, u16 type,
-                                    void *daddr, void *saddr, unsigned len),
-          cycx_netdevice_rebuild_header(struct sk_buff *skb),
-          cycx_netdevice_hard_start_xmit(struct sk_buff *skb,
+static int cycx_netdevice_init(struct net_device *dev);
+static int cycx_netdevice_open(struct net_device *dev);
+static int cycx_netdevice_stop(struct net_device *dev);
+static int cycx_netdevice_hard_header(struct sk_buff *skb,
+                                     struct net_device *dev, u16 type,
+                                     const void *daddr, const void *saddr,
+                                     unsigned len);
+static int cycx_netdevice_rebuild_header(struct sk_buff *skb);
+static int cycx_netdevice_hard_start_xmit(struct sk_buff *skb,
                                          struct net_device *dev);
 
 static struct net_device_stats *
@@ -468,7 +469,14 @@ static int cycx_wan_del_if(struct wan_device *wandev, struct net_device *dev)
        return 0;
 }
 
+
 /* Network Device Interface */
+
+static const struct header_ops cycx_header_ops = {
+       .create = cycx_netdevice_hard_header,
+       .rebuild = cycx_netdevice_rebuild_header,
+};
+
 /* Initialize Linux network interface.
  *
  * This routine is called only once for each interface, during Linux network
@@ -483,8 +491,8 @@ static int cycx_netdevice_init(struct net_device *dev)
        /* Initialize device driver entry points */
        dev->open               = cycx_netdevice_open;
        dev->stop               = cycx_netdevice_stop;
-       dev->hard_header        = cycx_netdevice_hard_header;
-       dev->rebuild_header     = cycx_netdevice_rebuild_header;
+       dev->header_ops         = &cycx_header_ops;
+
        dev->hard_start_xmit    = cycx_netdevice_hard_start_xmit;
        dev->get_stats          = cycx_netdevice_get_stats;
 
@@ -554,7 +562,8 @@ static int cycx_netdevice_stop(struct net_device *dev)
  * Return:     media header length. */
 static int cycx_netdevice_hard_header(struct sk_buff *skb,
                                      struct net_device *dev, u16 type,
-                                     void *daddr, void *saddr, unsigned len)
+                                     const void *daddr, const void *saddr,
+                                     unsigned len)
 {
        skb->protocol = type;
 
index bc12810157e09449a956bd2b0e6661d5d4cddd0d..96b232446c0b03533851be84da4b158e775f38a1 100644 (file)
@@ -66,8 +66,8 @@ static void dlci_setup(struct net_device *);
  */
 
 static int dlci_header(struct sk_buff *skb, struct net_device *dev, 
-                           unsigned short type, void *daddr, void *saddr, 
-                           unsigned len)
+                      unsigned short type, const void *daddr,
+                      const void *saddr, unsigned len)
 {
        struct frhdr            hdr;
        struct dlci_local       *dlp;
@@ -485,6 +485,10 @@ static int dlci_ioctl(unsigned int cmd, void __user *arg)
        return(err);
 }
 
+static const struct header_ops dlci_header_ops = {
+       .create = dlci_header,
+};
+
 static void dlci_setup(struct net_device *dev)
 {
        struct dlci_local *dlp = dev->priv;
@@ -494,7 +498,7 @@ static void dlci_setup(struct net_device *dev)
        dev->stop               = dlci_close;
        dev->do_ioctl           = dlci_dev_ioctl;
        dev->hard_start_xmit    = dlci_transmit;
-       dev->hard_header        = dlci_header;
+       dev->header_ops         = &dlci_header_ops;
        dev->get_stats          = dlci_get_stats;
        dev->change_mtu         = dlci_change_mtu;
        dev->destructor         = free_netdev;
index ee23b91f23d9b860ee2a6b5947e33ec683e20e79..d553e6f328513a56f633bf35d2e562c5d979f08f 100644 (file)
@@ -232,6 +232,8 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        return -EINVAL;
 }
 
+static const struct header_ops hdlc_null_ops;
+
 static void hdlc_setup_dev(struct net_device *dev)
 {
        /* Re-init all variables changed by HDLC protocol drivers,
@@ -243,13 +245,9 @@ static void hdlc_setup_dev(struct net_device *dev)
        dev->type                = ARPHRD_RAWHDLC;
        dev->hard_header_len     = 16;
        dev->addr_len            = 0;
-       dev->hard_header         = NULL;
-       dev->rebuild_header      = NULL;
-       dev->set_mac_address     = NULL;
-       dev->hard_header_cache   = NULL;
-       dev->header_cache_update = NULL;
+       dev->header_ops          = &hdlc_null_ops;
+
        dev->change_mtu          = hdlc_change_mtu;
-       dev->hard_header_parse   = NULL;
 }
 
 static void hdlc_setup(struct net_device *dev)
index 9ec6cf2e510ee32510fd3002f762476efe183031..038a6e748bbffdcfdd39bca117709f65f5510bb0 100644 (file)
@@ -74,7 +74,7 @@ static inline struct cisco_state * state(hdlc_device *hdlc)
 
 
 static int cisco_hard_header(struct sk_buff *skb, struct net_device *dev,
-                            u16 type, void *daddr, void *saddr,
+                            u16 type, const void *daddr, const void *saddr,
                             unsigned int len)
 {
        struct hdlc_header *data;
@@ -309,7 +309,6 @@ static void cisco_stop(struct net_device *dev)
 }
 
 
-
 static struct hdlc_proto proto = {
        .start          = cisco_start,
        .stop           = cisco_stop,
@@ -317,7 +316,10 @@ static struct hdlc_proto proto = {
        .ioctl          = cisco_ioctl,
        .module         = THIS_MODULE,
 };
+
+static const struct header_ops cisco_header_ops = {
+       .create = cisco_hard_header,
+};
  
 static int cisco_ioctl(struct net_device *dev, struct ifreq *ifr)
 {
@@ -365,7 +367,7 @@ static int cisco_ioctl(struct net_device *dev, struct ifreq *ifr)
 
                memcpy(&state(hdlc)->settings, &new_settings, size);
                dev->hard_start_xmit = hdlc->xmit;
-               dev->hard_header = cisco_hard_header;
+               dev->header_ops = &cisco_header_ops;
                dev->type = ARPHRD_CISCO;
                netif_dormant_on(dev);
                return 0;
index 4591437dd2f3dca75470b5d259bdaed8f1d65c5e..3caeb528eacea2f247820a6e2f65e181c54f9e2e 100644 (file)
@@ -73,7 +73,7 @@ static void ppp_close(struct net_device *dev)
 
        sppp_close(dev);
        sppp_detach(dev);
-       dev->rebuild_header = NULL;
+
        dev->change_mtu = state(hdlc)->old_change_mtu;
        dev->mtu = HDLC_MAX_MTU;
        dev->hard_header_len = 16;
index 31e1799571add1818688bc23f8d326e38178b0c3..426c0678d9830c2725f2802009ab37d0e29ff405 100644 (file)
@@ -111,7 +111,7 @@ void lmc_proto_attach(lmc_softc_t *sc) /*FOLD00*/
              * They set a few basics because they don't use sync_ppp
              */
             dev->flags |= IFF_POINTOPOINT;
-            dev->hard_header = NULL;
+
             dev->hard_header_len = 0;
             dev->addr_len = 0;
         }
index 5c71af6ea3a50ad99d91845fbce3247cbebdf7d8..232ecba5340fb1f703c20218e1c09c9dfa156a1f 100644 (file)
@@ -359,8 +359,10 @@ done:
  *     Handle transmit packets.
  */
  
-static int sppp_hard_header(struct sk_buff *skb, struct net_device *dev, __u16 type,
-               void *daddr, void *saddr, unsigned int len)
+static int sppp_hard_header(struct sk_buff *skb,
+                           struct net_device *dev, __u16 type,
+                           const void *daddr, const void *saddr,
+                           unsigned int len)
 {
        struct sppp *sp = (struct sppp *)sppp_of(dev);
        struct ppp_header *h;
@@ -392,10 +394,9 @@ static int sppp_hard_header(struct sk_buff *skb, struct net_device *dev, __u16 t
        return sizeof(struct ppp_header);
 }
 
-static int sppp_rebuild_header(struct sk_buff *skb)
-{
-       return 0;
-}
+static const struct header_ops sppp_header_ops = {
+       .create = sppp_hard_header,
+};
 
 /*
  * Send keepalive packets, every 10 seconds.
@@ -1098,8 +1099,8 @@ void sppp_attach(struct ppp_device *pd)
         *      hard_start_xmit.
         */
         
-       dev->hard_header = sppp_hard_header;
-       dev->rebuild_header = sppp_rebuild_header;
+       dev->header_ops = &sppp_header_ops;
+
        dev->tx_queue_len = 10;
        dev->type = ARPHRD_HDLC;
        dev->addr_len = 0;
@@ -1115,8 +1116,6 @@ void sppp_attach(struct ppp_device *pd)
        dev->stop = sppp_close;
 #endif 
        dev->change_mtu = sppp_change_mtu;
-       dev->hard_header_cache = NULL;
-       dev->header_cache_update = NULL;
        dev->flags = IFF_MULTICAST|IFF_POINTOPOINT|IFF_NOARP;
 }
 
index cd03a61359aac2bfb0e3052f6840bb42fc2a7936..074055e18c5c510d879fafc903e9f65b27fae752 100644 (file)
@@ -2696,9 +2696,13 @@ static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci)
        return rc;
 }
 
+static const struct header_ops airo_header_ops = {
+       .parse = wll_header_parse,
+};
+
 static void wifi_setup(struct net_device *dev)
 {
-       dev->hard_header_parse  = wll_header_parse;
+       dev->header_ops = &airo_header_ops;
        dev->hard_start_xmit = &airo_start_xmit11;
        dev->get_stats = &airo_get_stats;
        dev->set_mac_address = &airo_set_mac_address;
index ef37a75d550b863cf4180fb4b466b00f4233b79f..951df83702f9dfed6c8296f9c25e53d7b97f22cb 100644 (file)
@@ -30,8 +30,7 @@ void hostap_dump_rx_header(const char *name,
                           const struct hfa384x_rx_frame *rx);
 void hostap_dump_tx_header(const char *name,
                           const struct hfa384x_tx_frame *tx);
-int hostap_80211_header_parse(struct sk_buff *skb, unsigned char *haddr);
-int hostap_80211_prism_header_parse(struct sk_buff *skb, unsigned char *haddr);
+extern const struct header_ops hostap_80211_ops;
 int hostap_80211_get_hdrlen(u16 fc);
 struct net_device_stats *hostap_get_stats(struct net_device *dev);
 void hostap_setup_dev(struct net_device *dev, local_info_t *local,
index 7fa7ab0a4b23d448ecd596e27f751dc4611223fe..b20bb013d57ea79f3871cba185567b2eea4f550d 100644 (file)
@@ -3258,11 +3258,10 @@ while (0)
        INIT_LIST_HEAD(&local->bss_list);
 
        hostap_setup_dev(dev, local, 1);
-       local->saved_eth_header_parse = dev->hard_header_parse;
 
        dev->hard_start_xmit = hostap_master_start_xmit;
        dev->type = ARPHRD_IEEE80211;
-       dev->hard_header_parse = hostap_80211_header_parse;
+       dev->header_ops = &hostap_80211_ops;
 
        rtnl_lock();
        ret = dev_alloc_name(dev, "wifi%d");
index 7036ecff5ec1c9a3312f0c5f30041e0c020aa411..40f516d42c5e39894f4c14f45582852ce116fb7b 100644 (file)
@@ -897,11 +897,8 @@ static void hostap_monitor_set_type(local_info_t *local)
        if (local->monitor_type == PRISM2_MONITOR_PRISM ||
            local->monitor_type == PRISM2_MONITOR_CAPHDR) {
                dev->type = ARPHRD_IEEE80211_PRISM;
-               dev->hard_header_parse =
-                       hostap_80211_prism_header_parse;
        } else {
                dev->type = ARPHRD_IEEE80211;
-               dev->hard_header_parse = hostap_80211_header_parse;
        }
 }
 
@@ -1141,7 +1138,7 @@ static int hostap_monitor_mode_disable(local_info_t *local)
 
        printk(KERN_DEBUG "%s: Disabling monitor mode\n", dev->name);
        dev->type = ARPHRD_ETHER;
-       dev->hard_header_parse = local->saved_eth_header_parse;
+
        if (local->func->cmd(dev, HFA384X_CMDCODE_TEST |
                             (HFA384X_TEST_STOP << 8),
                             0, NULL, NULL))
index 4cb09d81b404efad59388d8f73cda14d60d80d3e..b75cf9205ce026902b2042b600c9d430b5ecdc3e 100644 (file)
@@ -594,24 +594,27 @@ void hostap_dump_tx_header(const char *name, const struct hfa384x_tx_frame *tx)
 }
 
 
-int hostap_80211_header_parse(struct sk_buff *skb, unsigned char *haddr)
+int hostap_80211_header_parse(const struct sk_buff *skb, unsigned char *haddr)
 {
-       memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */
-       return ETH_ALEN;
-}
-
+       struct hostap_interface *iface = netdev_priv(skb->dev);
+       local_info_t *local = iface->local;
+
+       if (local->monitor_type == PRISM2_MONITOR_PRISM ||
+           local->monitor_type == PRISM2_MONITOR_CAPHDR) {
+               const unsigned char *mac = skb_mac_header(skb);
+
+               if (*(u32 *)mac == LWNG_CAP_DID_BASE) {
+                       memcpy(haddr,
+                              mac + sizeof(struct linux_wlan_ng_prism_hdr) + 10,
+                              ETH_ALEN); /* addr2 */
+               } else { /* (*(u32 *)mac == htonl(LWNG_CAPHDR_VERSION)) */
+                       memcpy(haddr,
+                              mac + sizeof(struct linux_wlan_ng_cap_hdr) + 10,
+                              ETH_ALEN); /* addr2 */
+               }
+       } else
+               memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */
 
-int hostap_80211_prism_header_parse(struct sk_buff *skb, unsigned char *haddr)
-{
-       const unsigned char *mac = skb_mac_header(skb);
-
-       if (*(u32 *)mac == LWNG_CAP_DID_BASE) {
-               memcpy(haddr, mac + sizeof(struct linux_wlan_ng_prism_hdr) + 10,
-                      ETH_ALEN); /* addr2 */
-       } else { /* (*(u32 *)mac == htonl(LWNG_CAPHDR_VERSION)) */
-               memcpy(haddr, mac + sizeof(struct linux_wlan_ng_cap_hdr) + 10,
-                      ETH_ALEN); /* addr2 */
-       }
        return ETH_ALEN;
 }
 
@@ -843,6 +846,15 @@ static void prism2_tx_timeout(struct net_device *dev)
        local->func->schedule_reset(local);
 }
 
+const struct header_ops hostap_80211_ops = {
+       .create         = eth_header,
+       .rebuild        = eth_rebuild_header,
+       .cache          = eth_header_cache,
+       .cache_update   = eth_header_cache_update,
+
+       .parse          = hostap_80211_header_parse,
+};
+EXPORT_SYMBOL(hostap_80211_ops);
 
 void hostap_setup_dev(struct net_device *dev, local_info_t *local,
                      int main_dev)
@@ -883,7 +895,6 @@ void hostap_setup_dev(struct net_device *dev, local_info_t *local,
        netif_stop_queue(dev);
 }
 
-
 static int hostap_enable_hostapd(local_info_t *local, int rtnl_locked)
 {
        struct net_device *dev = local->dev;
@@ -901,7 +912,7 @@ static int hostap_enable_hostapd(local_info_t *local, int rtnl_locked)
 
        local->apdev->hard_start_xmit = hostap_mgmt_start_xmit;
        local->apdev->type = ARPHRD_IEEE80211;
-       local->apdev->hard_header_parse = hostap_80211_header_parse;
+       local->apdev->header_ops = &hostap_80211_ops;
 
        return 0;
 }
index a42325c145b40832290c1df94eec12794c1bb942..c27b2c1c06af5de29aedbd996e32dc2787423866 100644 (file)
@@ -736,8 +736,6 @@ struct local_info {
                PRISM2_MONITOR_80211 = 0, PRISM2_MONITOR_PRISM = 1,
                PRISM2_MONITOR_CAPHDR = 2
        } monitor_type;
-       int (*saved_eth_header_parse)(struct sk_buff *skb,
-                                     unsigned char *haddr);
        int monitor_allow_fcserr;
 
        int hostapd; /* whether user space daemon, hostapd, is used for AP
index 404cd1512312c1ce2adb6f598c7f6313ba4c09e8..4bd14b331862948f558a74955b9c191b7f4502f4 100644 (file)
@@ -1631,8 +1631,8 @@ static void strip_IdleTask(unsigned long parameter)
  */
 
 static int strip_header(struct sk_buff *skb, struct net_device *dev,
-                       unsigned short type, void *daddr, void *saddr,
-                       unsigned len)
+                       unsigned short type, const void *daddr,
+                       const void *saddr, unsigned len)
 {
        struct strip *strip_info = netdev_priv(dev);
        STRIP_Header *header = (STRIP_Header *) skb_push(skb, sizeof(STRIP_Header));
@@ -2497,6 +2497,11 @@ static int strip_close_low(struct net_device *dev)
        return 0;
 }
 
+static const struct header_ops strip_header_ops = {
+       .create = strip_header,
+       .rebuild = strip_rebuild_header,
+};
+
 /*
  * This routine is called by DDI when the
  * (dynamically assigned) device is registered
@@ -2531,8 +2536,8 @@ static void strip_dev_setup(struct net_device *dev)
        dev->open = strip_open_low;
        dev->stop = strip_close_low;
        dev->hard_start_xmit = strip_xmit;
-       dev->hard_header = strip_header;
-       dev->rebuild_header = strip_rebuild_header;
+       dev->header_ops = &strip_header_ops;
+
        dev->set_mac_address = strip_set_mac_address;
        dev->get_stats = strip_get_stats;
        dev->change_mtu = strip_change_mtu;
index 6d4959807abcc0e291f217bfcccb6898360c2de9..8c6b72d05b1d63e9655bf19223704182f74a18f7 100644 (file)
@@ -833,8 +833,7 @@ struct qeth_card {
        struct qeth_qdio_info qdio;
        struct qeth_perf_stats perf_stats;
        int use_hard_stop;
-       int (*orig_hard_header)(struct sk_buff *,struct net_device *,
-                               unsigned short,void *,void *,unsigned);
+       const struct header_ops *orig_header_ops;
        struct qeth_osn_info osn_info;
        atomic_t force_alloc_skb;
 };
index 65225b3989ddcbe6cfcfd124ad6599158fa4ca40..778ddfb990777f91c8b713517f58b3e21355bceb 100644 (file)
@@ -160,6 +160,9 @@ qeth_set_multicast_list(struct net_device *);
 static void
 qeth_setadp_promisc_mode(struct qeth_card *);
 
+static int
+qeth_hard_header_parse(const struct sk_buff *skb, unsigned char *haddr);
+
 static void
 qeth_notify_processes(void)
 {
@@ -3787,8 +3790,8 @@ qeth_get_netdevice(enum qeth_card_types type, enum qeth_link_types linktype)
 /*hard_header fake function; used in case fake_ll is set */
 static int
 qeth_fake_header(struct sk_buff *skb, struct net_device *dev,
-                    unsigned short type, void *daddr, void *saddr,
-                    unsigned len)
+                unsigned short type, const void *daddr, const void *saddr,
+                unsigned len)
 {
        if(dev->type == ARPHRD_IEEE802_TR){
                struct trh_hdr *hdr;
@@ -3811,6 +3814,11 @@ qeth_fake_header(struct sk_buff *skb, struct net_device *dev,
        }
 }
 
+static const struct header_ops qeth_fake_ops = {
+       .create = qeth_fake_header,
+       .parse  = qeth_hard_header_parse,
+};
+
 static int
 qeth_send_packet(struct qeth_card *, struct sk_buff *);
 
@@ -4649,7 +4657,7 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
                [qeth_get_priority_queue(card, skb, ipv, cast_type)];
        if (!card->options.layer2) {
                ipv = qeth_get_ip_version(skb);
-               if ((card->dev->hard_header == qeth_fake_header) && ipv) {
+               if ((card->dev->header_ops == &qeth_fake_ops) && ipv) {
                        new_skb = qeth_pskb_unshare(skb, GFP_ATOMIC);
                        if (!new_skb)
                                return -ENOMEM;
@@ -6566,6 +6574,9 @@ qeth_hard_header_parse(const struct sk_buff *skb, unsigned char *haddr)
        const struct qeth_card *card;
        const struct ethhdr *eth;
 
+       if (dev->type != ARPHRD_IEEE802_TR)
+               return 0;
+
        card = qeth_get_card_from_dev(skb->dev);
        if (card->options.layer2)
                goto haveheader;
@@ -6596,6 +6607,10 @@ haveheader:
        return ETH_ALEN;
 }
 
+static const struct header_ops qeth_null_ops = {
+       .parse = qeth_hard_header_parse,
+};
+
 static int
 qeth_netdev_init(struct net_device *dev)
 {
@@ -6620,12 +6635,8 @@ qeth_netdev_init(struct net_device *dev)
        dev->vlan_rx_kill_vid = qeth_vlan_rx_kill_vid;
        dev->vlan_rx_add_vid = qeth_vlan_rx_add_vid;
 #endif
-       if (qeth_get_netdev_flags(card) & IFF_NOARP) {
-               dev->rebuild_header = NULL;
-               dev->hard_header = NULL;
-               dev->header_cache_update = NULL;
-               dev->hard_header_cache = NULL;
-       }
+       dev->header_ops = &qeth_null_ops;
+
 #ifdef CONFIG_QETH_IPV6
        /*IPv6 address autoconfiguration stuff*/
        if (!(card->info.unique_id & UNIQUE_ID_NOT_BY_CARD))
@@ -6633,11 +6644,8 @@ qeth_netdev_init(struct net_device *dev)
 #endif
        if (card->options.fake_ll &&
                (qeth_get_netdev_flags(card) & IFF_NOARP))
-                       dev->hard_header = qeth_fake_header;
-       if (dev->type == ARPHRD_IEEE802_TR)
-               dev->hard_header_parse = NULL;
-       else
-               dev->hard_header_parse = qeth_hard_header_parse;
+                       dev->header_ops = &qeth_fake_ops;
+
        dev->set_mac_address = qeth_layer2_set_mac_address;
        dev->flags |= qeth_get_netdev_flags(card);
        if ((card->options.fake_broadcast) ||
@@ -6740,10 +6748,10 @@ retry:
        }
        /*network device will be recovered*/
        if (card->dev) {
-               card->dev->hard_header = card->orig_hard_header;
+               card->dev->header_ops = card->orig_header_ops;
                if (card->options.fake_ll &&
                    (qeth_get_netdev_flags(card) & IFF_NOARP))
-                       card->dev->hard_header = qeth_fake_header;
+                       card->dev->header_ops = &qeth_fake_ops;
                return 0;
        }
        /* at first set_online allocate netdev */
@@ -6757,7 +6765,7 @@ retry:
                goto out;
        }
        card->dev->priv = card;
-       card->orig_hard_header = card->dev->hard_header;
+       card->orig_header_ops = card->dev->header_ops;
        card->dev->type = qeth_get_arphdr_type(card->info.type,
                                               card->info.link_type);
        card->dev->init = qeth_netdev_init;
@@ -8308,7 +8316,7 @@ qeth_arp_constructor(struct neighbour *neigh)
        if (card == NULL)
                goto out;
        if((card->options.layer2) ||
-          (card->dev->hard_header == qeth_fake_header))
+          (card->dev->header_ops == &qeth_fake_ops))
                goto out;
 
        rcu_read_lock();
index 6cdb97365e4734abde2ab88a04f9745661385912..b7558ec81ed58117042520f8cb7d764028252c60 100644 (file)
 #include <linux/random.h>
 
 #ifdef __KERNEL__
-extern int             eth_header(struct sk_buff *skb, struct net_device *dev,
-                                  unsigned short type, void *daddr,
-                                  void *saddr, unsigned len);
-extern int             eth_rebuild_header(struct sk_buff *skb);
 extern __be16          eth_type_trans(struct sk_buff *skb, struct net_device *dev);
-extern void            eth_header_cache_update(struct hh_cache *hh, struct net_device *dev,
-                                               unsigned char * haddr);
-extern int             eth_header_cache(struct neighbour *neigh,
-                                        struct hh_cache *hh);
+extern const struct header_ops eth_header_ops;
+
+extern int eth_header(struct sk_buff *skb, struct net_device *dev,
+                     unsigned short type,
+                     const void *daddr, const void *saddr, unsigned len);
+extern int eth_rebuild_header(struct sk_buff *skb);
+extern int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr);
+extern int eth_header_cache(const struct neighbour *neigh, struct hh_cache *hh);
+extern void eth_header_cache_update(struct hh_cache *hh,
+                                   const struct net_device *dev,
+                                   const unsigned char *haddr);
+
 
 extern struct net_device *alloc_etherdev_mq(int sizeof_priv, unsigned int queue_count);
 #define alloc_etherdev(sizeof_priv) alloc_etherdev_mq(sizeof_priv, 1)
index 0e791e2c0c5a6e2a12651888aabdef699d263f5e..5f9297793661784f05d2e8567f6f4eddc36d43b8 100644 (file)
@@ -117,6 +117,8 @@ static inline struct ethhdr *eth_hdr(const struct sk_buff *skb)
        return (struct ethhdr *)skb_mac_header(skb);
 }
 
+int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr);
+
 #ifdef CONFIG_SYSCTL
 extern struct ctl_table ether_table[];
 #endif
index 51574743aa1ba16f519fe4c9d8de69ad72c2db0c..3b1b7ba198250955db9e53da9d7006e0616149f9 100644 (file)
@@ -25,17 +25,6 @@ struct shaper
                                   an empty queue */
        spinlock_t lock;
        struct net_device *dev;
-       int  (*hard_start_xmit) (struct sk_buff *skb,
-               struct net_device *dev);
-       int  (*hard_header) (struct sk_buff *skb,
-               struct net_device *dev,
-               unsigned short type,
-               void *daddr,
-               void *saddr,
-               unsigned len);
-       int  (*rebuild_header)(struct sk_buff *skb);
-       int (*hard_header_cache)(struct neighbour *neigh, struct hh_cache *hh);
-       void (*header_cache_update)(struct hh_cache *hh, struct net_device *dev, unsigned char *  haddr);
        struct net_device_stats* (*get_stats)(struct net_device *dev);
        struct timer_list timer;
 };
index 3c7875b7ab5be00cd0ee375cf61904be3c6ca122..a6fb366748bb4e82eed7ff8f5ced81094d2a3c42 100644 (file)
@@ -353,13 +353,6 @@ typedef struct isdn_net_local_s {
                                        /* a particular channel (including  */
                                        /* the frame_cnt                    */
 
-  int                    (*org_hhc)(
-                                   struct neighbour *neigh,
-                                   struct hh_cache *hh);
-                                       /* Ptr to orig. header_cache_update */
-  void                   (*org_hcu)(struct hh_cache *,
-                                   struct net_device *,
-                                    unsigned char *);
   int  pppbind;                        /* ippp device for bindings         */
   int                                  dialtimeout;    /* How long shall we try on dialing? (jiffies) */
   int                                  dialwait;               /* How long shall we wait after failed attempt? (jiffies) */
index aae9ec367f5d295c4e0fb6d1cbeee42186ccac4f..91cd3f3db5079a06a214b53c98b04ea60dd70c08 100644 (file)
@@ -250,6 +250,19 @@ struct hh_cache
 #define LL_RESERVED_SPACE_EXTRA(dev,extra) \
        ((((dev)->hard_header_len+extra)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
 
+struct header_ops {
+       int     (*create) (struct sk_buff *skb, struct net_device *dev,
+                          unsigned short type, const void *daddr,
+                          const void *saddr, unsigned len);
+       int     (*parse)(const struct sk_buff *skb, unsigned char *haddr);
+       int     (*rebuild)(struct sk_buff *skb);
+#define HAVE_HEADER_CACHE
+       int     (*cache)(const struct neighbour *neigh, struct hh_cache *hh);
+       void    (*cache_update)(struct hh_cache *hh,
+                               const struct net_device *dev,
+                               const unsigned char *haddr);
+};
+
 /* These flag bits are private to the generic network queueing
  * layer, they may not be explicitly referenced by any other
  * code.
@@ -492,6 +505,9 @@ struct net_device
 #endif
        const struct ethtool_ops *ethtool_ops;
 
+       /* Hardware header description */
+       const struct header_ops *header_ops;
+
        /*
         * This marks the end of the "visible" part of the structure. All
         * fields hereafter are internal to the system, and may change at
@@ -615,13 +631,6 @@ struct net_device
        int                     (*open)(struct net_device *dev);
        int                     (*stop)(struct net_device *dev);
 #define HAVE_NETDEV_POLL
-       int                     (*hard_header) (struct sk_buff *skb,
-                                               struct net_device *dev,
-                                               unsigned short type,
-                                               void *daddr,
-                                               void *saddr,
-                                               unsigned len);
-       int                     (*rebuild_header)(struct sk_buff *skb);
 #define HAVE_CHANGE_RX_FLAGS
        void                    (*change_rx_flags)(struct net_device *dev,
                                                   int flags);
@@ -638,12 +647,6 @@ struct net_device
 #define HAVE_SET_CONFIG
        int                     (*set_config)(struct net_device *dev,
                                              struct ifmap *map);
-#define HAVE_HEADER_CACHE
-       int                     (*hard_header_cache)(struct neighbour *neigh,
-                                                    struct hh_cache *hh);
-       void                    (*header_cache_update)(struct hh_cache *hh,
-                                                      struct net_device *dev,
-                                                      unsigned char *  haddr);
 #define HAVE_CHANGE_MTU
        int                     (*change_mtu)(struct net_device *dev, int new_mtu);
 
@@ -657,8 +660,6 @@ struct net_device
        void                    (*vlan_rx_kill_vid)(struct net_device *dev,
                                                    unsigned short vid);
 
-       int                     (*hard_header_parse)(const struct sk_buff *skb,
-                                                    unsigned char *haddr);
        int                     (*neigh_setup)(struct net_device *dev, struct neigh_parms *);
 #ifdef CONFIG_NETPOLL
        struct netpoll_info     *npinfo;
@@ -802,11 +803,13 @@ extern int                netpoll_trap(void);
 
 static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev,
                                  unsigned short type,
-                                 void *daddr, void *saddr, unsigned len)
+                                 const void *daddr, const void *saddr,
+                                 unsigned len)
 {
-       if (!dev->hard_header)
+       if (!dev->header_ops)
                return 0;
-       return dev->hard_header(skb, dev, type, daddr, saddr, len);
+
+       return dev->header_ops->create(skb, dev, type, daddr, saddr, len);
 }
 
 static inline int dev_parse_header(const struct sk_buff *skb,
@@ -814,9 +817,9 @@ static inline int dev_parse_header(const struct sk_buff *skb,
 {
        const struct net_device *dev = skb->dev;
 
-       if (!dev->hard_header_parse)
+       if (!dev->header_ops->parse)
                return 0;
-       return dev->hard_header_parse(skb, haddr);
+       return dev->header_ops->parse(skb, haddr);
 }
 
 typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len);
index 99a4e364c74ae6db4efa55849890617e11cc7258..4e3cd93f81fcf0418f1fea085afcc91008d7f992 100644 (file)
@@ -363,8 +363,11 @@ extern int  ax25_rx_iframe(ax25_cb *, struct sk_buff *);
 extern int  ax25_kiss_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *);
 
 /* ax25_ip.c */
-extern int  ax25_hard_header(struct sk_buff *, struct net_device *, unsigned short, void *, void *, unsigned int);
+extern int ax25_hard_header(struct sk_buff *, struct net_device *,
+                           unsigned short, const void *,
+                           const void *, unsigned int);
 extern int  ax25_rebuild_header(struct sk_buff *);
+extern const struct header_ops ax25_header_ops;
 
 /* ax25_out.c */
 extern ax25_cb *ax25_send_frame(struct sk_buff *, int, ax25_address *, ax25_address *, ax25_digi *, struct net_device *);
index 9e22526e80e72b646c2a1f5eab446a88025731d0..ab61809a9616af402d8d197da3fc58a89b05e69c 100644 (file)
@@ -97,10 +97,9 @@ extern int tc_classify(struct sk_buff *skb, struct tcf_proto *tp,
 /* Calculate maximal size of packet seen by hard_start_xmit
    routine of this device.
  */
-static inline unsigned psched_mtu(struct net_device *dev)
+static inline unsigned psched_mtu(const struct net_device *dev)
 {
-       unsigned mtu = dev->mtu;
-       return dev->hard_header ? mtu + dev->hard_header_len : mtu;
+       return dev->mtu + dev->hard_header_len;
 }
 
 #endif
index 675d9ba8e591bf78803a09ecd3fcfa32596224b7..cb3475ea6fdada58337e7bf6e39773478afb0b7b 100644 (file)
@@ -35,7 +35,7 @@
 
 static int fc_header(struct sk_buff *skb, struct net_device *dev,
                     unsigned short type,
-                    void *daddr, void *saddr, unsigned len)
+                    const void *daddr, const void *saddr, unsigned len)
 {
        struct fch_hdr *fch;
        int hdr_len;
@@ -95,11 +95,14 @@ static int fc_rebuild_header(struct sk_buff *skb)
 #endif
 }
 
+static const struct header_ops fc_header_ops = {
+       .create  = fc_header,
+       .rebuild = fc_rebuild_header,
+};
+
 static void fc_setup(struct net_device *dev)
 {
-       dev->hard_header        = fc_header;
-       dev->rebuild_header     = fc_rebuild_header;
-
+       dev->header_ops         = &fc_header_ops;
        dev->type               = ARPHRD_IEEE802;
        dev->hard_header_len    = FC_HLEN;
        dev->mtu                = 2024;
index 91dde41b54819998d2db2e603611910da1604b77..0549317b935699f76c604bb06dabbee90492fec4 100644 (file)
@@ -52,7 +52,7 @@
 
 static int fddi_header(struct sk_buff *skb, struct net_device *dev,
                       unsigned short type,
-                      void *daddr, void *saddr, unsigned len)
+                      const void *daddr, const void *saddr, unsigned len)
 {
        int hl = FDDI_K_SNAP_HLEN;
        struct fddihdr *fddi;
@@ -175,11 +175,15 @@ static int fddi_change_mtu(struct net_device *dev, int new_mtu)
        return(0);
 }
 
+static const struct header_ops fddi_header_ops = {
+       .create         = fddi_header,
+       .rebuild        = fddi_rebuild_header,
+};
+
 static void fddi_setup(struct net_device *dev)
 {
        dev->change_mtu         = fddi_change_mtu;
-       dev->hard_header        = fddi_header;
-       dev->rebuild_header     = fddi_rebuild_header;
+       dev->header_ops         = &fddi_header_ops;
 
        dev->type               = ARPHRD_FDDI;
        dev->hard_header_len    = FDDI_K_SNAP_HLEN+3;   /* Assume 802.2 SNAP hdr len + 3 pad bytes */
index 87ffc12b6891826232ebba946f29c101e3b4b2dc..e35dc1e0915d27ad3b99da056541689327a7a70c 100644 (file)
@@ -45,8 +45,8 @@
  */
 
 static int hippi_header(struct sk_buff *skb, struct net_device *dev,
-                       unsigned short type, void *daddr, void *saddr,
-                       unsigned len)
+                       unsigned short type,
+                       const void *daddr, const void *saddr, unsigned len)
 {
        struct hippi_hdr *hip = (struct hippi_hdr *)skb_push(skb, HIPPI_HLEN);
        struct hippi_cb *hcb = (struct hippi_cb *) skb->cb;
@@ -182,16 +182,18 @@ static int hippi_neigh_setup_dev(struct net_device *dev, struct neigh_parms *p)
        return 0;
 }
 
+static const struct header_ops hippi_header_ops = {
+       .create         = hippi_header,
+       .rebuild        = hippi_rebuild_header,
+};
+
+
 static void hippi_setup(struct net_device *dev)
 {
        dev->set_multicast_list         = NULL;
        dev->change_mtu                 = hippi_change_mtu;
-       dev->hard_header                = hippi_header;
-       dev->rebuild_header             = hippi_rebuild_header;
+       dev->header_ops                 = &hippi_header_ops;
        dev->set_mac_address            = hippi_mac_addr;
-       dev->hard_header_parse          = NULL;
-       dev->hard_header_cache          = NULL;
-       dev->header_cache_update        = NULL;
        dev->neigh_setup                = hippi_neigh_setup_dev;
 
        /*
index aa3c2e936abc97bad75fc2ec8371ee72777238c8..a2bd0f2e3af84c85e5e0077963b2bd3616b69d93 100644 (file)
@@ -100,7 +100,7 @@ static inline unsigned long rif_hash(const unsigned char *addr)
 
 static int tr_header(struct sk_buff *skb, struct net_device *dev,
                     unsigned short type,
-                    void *daddr, void *saddr, unsigned len)
+                    const void *daddr, const void *saddr, unsigned len)
 {
        struct trh_hdr *trh;
        int hdr_len;
@@ -142,7 +142,7 @@ static int tr_header(struct sk_buff *skb, struct net_device *dev,
        if(daddr)
        {
                memcpy(trh->daddr,daddr,dev->addr_len);
-               tr_source_route(skb,trh,dev);
+               tr_source_route(skb, trh, dev);
                return(hdr_len);
        }
 
@@ -247,7 +247,8 @@ __be16 tr_type_trans(struct sk_buff *skb, struct net_device *dev)
  *     We try to do source routing...
  */
 
-void tr_source_route(struct sk_buff *skb,struct trh_hdr *trh,struct net_device *dev)
+void tr_source_route(struct sk_buff *skb,struct trh_hdr *trh,
+                    struct net_device *dev)
 {
        int slack;
        unsigned int hash;
@@ -592,14 +593,18 @@ static const struct file_operations rif_seq_fops = {
 
 #endif
 
+static const struct header_ops tr_header_ops = {
+       .create = tr_header,
+       .rebuild= tr_rebuild_header,
+};
+
 static void tr_setup(struct net_device *dev)
 {
        /*
         *      Configure and register
         */
 
-       dev->hard_header        = tr_header;
-       dev->rebuild_header     = tr_rebuild_header;
+       dev->header_ops = &tr_header_ops;
 
        dev->type               = ARPHRD_IEEE802_TR;
        dev->hard_header_len    = TR_HLEN;
index 4d003e391754378495d028cbb4bde60a942dd25f..f2bee234d361ae7ef0b957ea5398393333eefbb0 100644 (file)
@@ -314,6 +314,12 @@ int unregister_vlan_device(struct net_device *dev)
  */
 static struct lock_class_key vlan_netdev_xmit_lock_key;
 
+static const struct header_ops vlan_header_ops = {
+       .create  = vlan_dev_hard_header,
+       .rebuild = vlan_dev_rebuild_header,
+       .parse   = eth_header_parse,
+};
+
 static int vlan_dev_init(struct net_device *dev)
 {
        struct net_device *real_dev = VLAN_DEV_INFO(dev)->real_dev;
@@ -331,18 +337,14 @@ static int vlan_dev_init(struct net_device *dev)
                memcpy(dev->broadcast, real_dev->broadcast, dev->addr_len);
 
        if (real_dev->features & NETIF_F_HW_VLAN_TX) {
-               dev->hard_header     = real_dev->hard_header;
+               dev->header_ops      = real_dev->header_ops;
                dev->hard_header_len = real_dev->hard_header_len;
                dev->hard_start_xmit = vlan_dev_hwaccel_hard_start_xmit;
-               dev->rebuild_header  = real_dev->rebuild_header;
        } else {
-               dev->hard_header     = vlan_dev_hard_header;
+               dev->header_ops      = &vlan_header_ops;
                dev->hard_header_len = real_dev->hard_header_len + VLAN_HLEN;
                dev->hard_start_xmit = vlan_dev_hard_start_xmit;
-               dev->rebuild_header  = vlan_dev_rebuild_header;
        }
-       dev->hard_header_parse = real_dev->hard_header_parse;
-       dev->hard_header_cache = NULL;
 
        lockdep_set_class(&dev->_xmit_lock, &vlan_netdev_xmit_lock_key);
        return 0;
index 7df5b29355795382e6ceb5d334768f87c37fe9b6..cf4a80d06b3526f1ca2caf4e938561ec57c4dca9 100644 (file)
@@ -53,8 +53,8 @@ int vlan_dev_rebuild_header(struct sk_buff *skb);
 int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
                  struct packet_type *ptype, struct net_device *orig_dev);
 int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
-                        unsigned short type, void *daddr, void *saddr,
-                        unsigned len);
+                        unsigned short type, const void *daddr,
+                        const void *saddr, unsigned len);
 int vlan_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev);
 int vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb, struct net_device *dev);
 int vlan_dev_change_mtu(struct net_device *dev, int new_mtu);
index ca8090fdabbbd20129dab913cfe66d5aec21ede1..1a1740aa9a8b52ced5b71c4b2443b2eea773c0a7 100644 (file)
@@ -343,8 +343,8 @@ static inline unsigned short vlan_dev_get_egress_qos_mask(struct net_device* dev
  *  physical devices.
  */
 int vlan_dev_hard_header(struct sk_buff *skb, struct net_device *dev,
-                        unsigned short type, void *daddr, void *saddr,
-                        unsigned len)
+                        unsigned short type,
+                        const void *daddr, const void *saddr, unsigned len)
 {
        struct vlan_hdr *vhdr;
        unsigned short veth_TCI = 0;
index 9e4dffc1e42359b91027868f1fc73bd8062c7368..d856a62ab50fda448896689ff210e235dc8d0e6d 100644 (file)
@@ -24,11 +24,7 @@ static void ltalk_setup(struct net_device *dev)
        /* Fill in the fields of the device structure with localtalk-generic values. */
 
        dev->change_mtu         = ltalk_change_mtu;
-       dev->hard_header        = NULL;
-       dev->rebuild_header     = NULL;
        dev->set_mac_address    = ltalk_mac_addr;
-       dev->hard_header_cache  = NULL;
-       dev->header_cache_update= NULL;
 
        dev->type               = ARPHRD_LOCALTLK;
        dev->hard_header_len    = LTALK_HLEN;
index 930e4918037f51031b6e2839c05b4163d29845b2..f047a57aa95c151be44c41a92d9e834a8c35cfb5 100644 (file)
@@ -46,7 +46,9 @@
 
 #ifdef CONFIG_INET
 
-int ax25_hard_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len)
+int ax25_hard_header(struct sk_buff *skb, struct net_device *dev,
+                    unsigned short type, const void *daddr,
+                    const void *saddr, unsigned len)
 {
        unsigned char *buff;
 
@@ -215,7 +217,9 @@ put:
 
 #else  /* INET */
 
-int ax25_hard_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len)
+int ax25_hard_header(struct sk_buff *skb, struct net_device *dev,
+                    unsigned short type, const void *daddr,
+                    const void *saddr, unsigned len)
 {
        return -AX25_HEADER_LEN;
 }
@@ -227,5 +231,12 @@ int ax25_rebuild_header(struct sk_buff *skb)
 
 #endif
 
+const struct header_ops ax25_header_ops = {
+       .create = ax25_hard_header,
+       .rebuild = ax25_rebuild_header,
+};
+
 EXPORT_SYMBOL(ax25_hard_header);
 EXPORT_SYMBOL(ax25_rebuild_header);
+EXPORT_SYMBOL(ax25_header_ops);
+
index 3923d513305092ab7198f58713786ea0176e2b9f..d99864662582d20e33fa569a4126d3eb5ec31a1d 100644 (file)
@@ -967,14 +967,6 @@ void dev_load(struct net *net, const char *name)
                request_module("%s", name);
 }
 
-static int default_rebuild_header(struct sk_buff *skb)
-{
-       printk(KERN_DEBUG "%s: default_rebuild_header called -- BUG!\n",
-              skb->dev ? skb->dev->name : "NULL!!!");
-       kfree_skb(skb);
-       return 1;
-}
-
 /**
  *     dev_open        - prepare an interface for use.
  *     @dev:   device to open
@@ -3561,14 +3553,6 @@ int register_netdevice(struct net_device *dev)
                }
        }
 
-       /*
-        *      nil rebuild_header routine,
-        *      that should be never called and used as just bug trap.
-        */
-
-       if (!dev->rebuild_header)
-               dev->rebuild_header = default_rebuild_header;
-
        ret = netdev_register_kobject(dev);
        if (ret)
                goto err_uninit;
index 10bcb9f8da5ce65abf9c62b65a2c1ae556b6d066..c52df858d0be10a597109bed466c860d1177e097 100644 (file)
@@ -897,8 +897,8 @@ out_unlock_bh:
 static void neigh_update_hhs(struct neighbour *neigh)
 {
        struct hh_cache *hh;
-       void (*update)(struct hh_cache*, struct net_device*, unsigned char *) =
-               neigh->dev->header_cache_update;
+       void (*update)(struct hh_cache*, const struct net_device*, const unsigned char *)
+               = neigh->dev->header_ops->cache_update;
 
        if (update) {
                for (hh = neigh->hh; hh; hh = hh->hh_next) {
@@ -1095,7 +1095,8 @@ static void neigh_hh_init(struct neighbour *n, struct dst_entry *dst,
                hh->hh_type = protocol;
                atomic_set(&hh->hh_refcnt, 0);
                hh->hh_next = NULL;
-               if (dev->hard_header_cache(n, hh)) {
+
+               if (dev->header_ops->cache(n, hh)) {
                        kfree(hh);
                        hh = NULL;
                } else {
@@ -1127,7 +1128,7 @@ int neigh_compat_output(struct sk_buff *skb)
 
        if (dev_hard_header(skb, dev, ntohs(skb->protocol), NULL, NULL,
                            skb->len) < 0 &&
-           dev->rebuild_header(skb))
+           dev->header_ops->rebuild(skb))
                return 0;
 
        return dev_queue_xmit(skb);
@@ -1149,7 +1150,7 @@ int neigh_resolve_output(struct sk_buff *skb)
        if (!neigh_event_send(neigh, skb)) {
                int err;
                struct net_device *dev = neigh->dev;
-               if (dev->hard_header_cache && !dst->hh) {
+               if (dev->header_ops->cache && !dst->hh) {
                        write_lock_bh(&neigh->lock);
                        if (!dst->hh)
                                neigh_hh_init(neigh, dst, dst->ops->protocol);
index bdeb2f0ace32e404680215ba98f008a39beefa17..ed8a3d49487dd263282d90e0cc91659b3fea0b7a 100644 (file)
@@ -75,8 +75,9 @@ __setup("ether=", netdev_boot_setup);
  * Set the protocol type. For a packet of type ETH_P_802_3 we put the length
  * in here instead. It is up to the 802.2 layer to carry protocol information.
  */
-int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
-              void *daddr, void *saddr, unsigned len)
+int eth_header(struct sk_buff *skb, struct net_device *dev,
+              unsigned short type,
+              const void *daddr, const void *saddr, unsigned len)
 {
        struct ethhdr *eth = (struct ethhdr *)skb_push(skb, ETH_HLEN);
 
@@ -109,6 +110,7 @@ int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
 
        return -ETH_HLEN;
 }
+EXPORT_SYMBOL(eth_header);
 
 /**
  * eth_rebuild_header- rebuild the Ethernet MAC header.
@@ -141,6 +143,7 @@ int eth_rebuild_header(struct sk_buff *skb)
 
        return 0;
 }
+EXPORT_SYMBOL(eth_rebuild_header);
 
 /**
  * eth_type_trans - determine the packet's protocol ID.
@@ -207,12 +210,13 @@ EXPORT_SYMBOL(eth_type_trans);
  * @skb: packet to extract header from
  * @haddr: destination buffer
  */
-static int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr)
+int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr)
 {
        const struct ethhdr *eth = eth_hdr(skb);
        memcpy(haddr, eth->h_source, ETH_ALEN);
        return ETH_ALEN;
 }
+EXPORT_SYMBOL(eth_header_parse);
 
 /**
  * eth_header_cache - fill cache entry from neighbour
@@ -220,11 +224,11 @@ static int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr)
  * @hh: destination cache entry
  * Create an Ethernet header template from the neighbour.
  */
-int eth_header_cache(struct neighbour *neigh, struct hh_cache *hh)
+int eth_header_cache(const struct neighbour *neigh, struct hh_cache *hh)
 {
        __be16 type = hh->hh_type;
        struct ethhdr *eth;
-       struct net_device *dev = neigh->dev;
+       const struct net_device *dev = neigh->dev;
 
        eth = (struct ethhdr *)
            (((u8 *) hh->hh_data) + (HH_DATA_OFF(sizeof(*eth))));
@@ -238,6 +242,7 @@ int eth_header_cache(struct neighbour *neigh, struct hh_cache *hh)
        hh->hh_len = ETH_HLEN;
        return 0;
 }
+EXPORT_SYMBOL(eth_header_cache);
 
 /**
  * eth_header_cache_update - update cache entry
@@ -247,12 +252,14 @@ int eth_header_cache(struct neighbour *neigh, struct hh_cache *hh)
  *
  * Called by Address Resolution module to notify changes in address.
  */
-void eth_header_cache_update(struct hh_cache *hh, struct net_device *dev,
-                            unsigned char *haddr)
+void eth_header_cache_update(struct hh_cache *hh,
+                            const struct net_device *dev,
+                            const unsigned char *haddr)
 {
        memcpy(((u8 *) hh->hh_data) + HH_DATA_OFF(sizeof(struct ethhdr)),
               haddr, ETH_ALEN);
 }
+EXPORT_SYMBOL(eth_header_cache_update);
 
 /**
  * eth_mac_addr - set new Ethernet hardware address
@@ -291,6 +298,14 @@ static int eth_change_mtu(struct net_device *dev, int new_mtu)
        return 0;
 }
 
+const struct header_ops eth_header_ops ____cacheline_aligned = {
+       .create         = eth_header,
+       .parse          = eth_header_parse,
+       .rebuild        = eth_rebuild_header,
+       .cache          = eth_header_cache,
+       .cache_update   = eth_header_cache_update,
+};
+
 /**
  * ether_setup - setup Ethernet network device
  * @dev: network device
@@ -298,13 +313,10 @@ static int eth_change_mtu(struct net_device *dev, int new_mtu)
  */
 void ether_setup(struct net_device *dev)
 {
+       dev->header_ops         = &eth_header_ops;
+
        dev->change_mtu         = eth_change_mtu;
-       dev->hard_header        = eth_header;
-       dev->rebuild_header     = eth_rebuild_header;
        dev->set_mac_address    = eth_mac_addr;
-       dev->hard_header_cache  = eth_header_cache;
-       dev->header_cache_update= eth_header_cache_update;
-       dev->hard_header_parse  = eth_header_parse;
 
        dev->type               = ARPHRD_ETHER;
        dev->hard_header_len    = ETH_HLEN;
index 5b24c65b13c6fa5fced2eb4b0f98127b3c232ca7..d8248198bcd721611336f38276ce84310ea53384 100644 (file)
@@ -253,7 +253,7 @@ static int arp_constructor(struct neighbour *neigh)
        neigh->parms = neigh_parms_clone(parms);
        rcu_read_unlock();
 
-       if (dev->hard_header == NULL) {
+       if (!dev->header_ops) {
                neigh->nud_state = NUD_NOARP;
                neigh->ops = &arp_direct_ops;
                neigh->output = neigh->ops->queue_xmit;
@@ -310,10 +310,12 @@ static int arp_constructor(struct neighbour *neigh)
                        neigh->nud_state = NUD_NOARP;
                        memcpy(neigh->ha, dev->broadcast, dev->addr_len);
                }
-               if (dev->hard_header_cache)
+
+               if (dev->header_ops->cache)
                        neigh->ops = &arp_hh_ops;
                else
                        neigh->ops = &arp_generic_ops;
+
                if (neigh->nud_state&NUD_VALID)
                        neigh->output = neigh->ops->connected_output;
                else
index ffa9f1c9dcbbb100e94bff144b0c4535456e370a..f151900efaf936b47fdec786f8bfd8152435b95b 100644 (file)
@@ -684,7 +684,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
                goto tx_error;
        }
 
-       if (dev->hard_header) {
+       if (dev->header_ops) {
                gre_hlen = 0;
                tiph = (struct iphdr*)skb->data;
        } else {
@@ -1063,8 +1063,9 @@ static int ipgre_tunnel_change_mtu(struct net_device *dev, int new_mtu)
 
  */
 
-static int ipgre_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
-                       void *daddr, void *saddr, unsigned len)
+static int ipgre_header(struct sk_buff *skb, struct net_device *dev,
+                       unsigned short type,
+                       const void *daddr, const void *saddr, unsigned len)
 {
        struct ip_tunnel *t = netdev_priv(dev);
        struct iphdr *iph = (struct iphdr *)skb_push(skb, t->hlen);
@@ -1091,6 +1092,10 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev, unsigned sh
        return -t->hlen;
 }
 
+static const struct header_ops ipgre_header_ops = {
+       .create = ipgre_header,
+};
+
 static int ipgre_open(struct net_device *dev)
 {
        struct ip_tunnel *t = netdev_priv(dev);
@@ -1187,7 +1192,7 @@ static int ipgre_tunnel_init(struct net_device *dev)
                        if (!iph->saddr)
                                return -EINVAL;
                        dev->flags = IFF_BROADCAST;
-                       dev->hard_header = ipgre_header;
+                       dev->header_ops = &ipgre_header_ops;
                        dev->open = ipgre_open;
                        dev->stop = ipgre_close;
                }
index 77f67b7cb9bffa509b2b96a36dc9a275ce6e23ef..699f06781fd891df9882d1c77c0c335f8d7a7252 100644 (file)
@@ -169,7 +169,7 @@ static inline int ip_finish_output2(struct sk_buff *skb)
                IP_INC_STATS(IPSTATS_MIB_OUTBCASTPKTS);
 
        /* Be paranoid, rather than too clever. */
-       if (unlikely(skb_headroom(skb) < hh_len && dev->hard_header)) {
+       if (unlikely(skb_headroom(skb) < hh_len && dev->header_ops)) {
                struct sk_buff *skb2;
 
                skb2 = skb_realloc_headroom(skb, LL_RESERVED_SPACE(dev));
index 7ea5a502ca084acd0dd8eb69426a77107eda8e4f..b761dbed8cec132f0436be2ee7def72f34a7c6fe 100644 (file)
@@ -354,7 +354,7 @@ static int ndisc_constructor(struct neighbour *neigh)
        rcu_read_unlock();
 
        neigh->type = is_multicast ? RTN_MULTICAST : RTN_UNICAST;
-       if (dev->hard_header == NULL) {
+       if (!dev->header_ops) {
                neigh->nud_state = NUD_NOARP;
                neigh->ops = &ndisc_direct_ops;
                neigh->output = neigh->ops->queue_xmit;
@@ -371,7 +371,7 @@ static int ndisc_constructor(struct neighbour *neigh)
                        neigh->nud_state = NUD_NOARP;
                        memcpy(neigh->ha, dev->broadcast, dev->addr_len);
                }
-               if (dev->hard_header_cache)
+               if (dev->header_ops->cache)
                        neigh->ops = &ndisc_hh_ops;
                else
                        neigh->ops = &ndisc_generic_ops;
@@ -807,7 +807,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
                neigh_update(neigh, lladdr, NUD_STALE,
                             NEIGH_UPDATE_F_WEAK_OVERRIDE|
                             NEIGH_UPDATE_F_OVERRIDE);
-       if (neigh || !dev->hard_header) {
+       if (neigh || !dev->header_ops) {
                ndisc_send_na(dev, neigh, saddr, &msg->target,
                              is_router,
                              1, (ifp != NULL && inc), inc);
index 0cdcf0d0c6ca847b059214da1df3ddeb440f2cc9..57ec8880bb1a98bc6fb36c9965b416a587dadbaf 100644 (file)
@@ -228,7 +228,6 @@ void ieee80211_if_mgmt_setup(struct net_device *dev)
        dev->open = ieee80211_mgmt_open;
        dev->stop = ieee80211_mgmt_stop;
        dev->type = ARPHRD_IEEE80211_PRISM;
-       dev->hard_header_parse = header_parse_80211;
        dev->uninit = ieee80211_if_reinit;
        dev->destructor = ieee80211_if_free;
 }
@@ -546,10 +545,19 @@ static void ieee80211_set_multicast_list(struct net_device *dev)
        netif_tx_unlock(local->mdev);
 }
 
+static const struct header_ops ieee80211_header_ops = {
+       .create         = eth_header,
+       .parse          = header_parse_80211,
+       .rebuild        = eth_rebuild_header,
+       .cache          = eth_header_cache,
+       .cache_update   = eth_header_cache_update,
+};
+
 /* Must not be called for mdev and apdev */
 void ieee80211_if_setup(struct net_device *dev)
 {
        ether_setup(dev);
+       dev->header_ops = &ieee80211_header_ops;
        dev->hard_start_xmit = ieee80211_subif_start_xmit;
        dev->wireless_handlers = &ieee80211_iw_handler_def;
        dev->set_multicast_list = ieee80211_set_multicast_list;
@@ -1197,7 +1205,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
        mdev->open = ieee80211_master_open;
        mdev->stop = ieee80211_master_stop;
        mdev->type = ARPHRD_IEEE80211;
-       mdev->hard_header_parse = header_parse_80211;
+       mdev->header_ops = &ieee80211_header_ops;
 
        sdata->type = IEEE80211_IF_TYPE_AP;
        sdata->dev = mdev;
index c7b5d930e7323b84313acf551939229a40663233..8c68da5ef0a17840a017dcf92993e8842d744952 100644 (file)
@@ -95,8 +95,9 @@ static int nr_rebuild_header(struct sk_buff *skb)
 
 #endif
 
-static int nr_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
-       void *daddr, void *saddr, unsigned len)
+static int nr_header(struct sk_buff *skb, struct net_device *dev,
+                    unsigned short type,
+                    const void *daddr, const void *saddr, unsigned len)
 {
        unsigned char *buff = skb_push(skb, NR_NETWORK_LEN + NR_TRANSPORT_LEN);
 
@@ -193,6 +194,12 @@ static struct net_device_stats *nr_get_stats(struct net_device *dev)
        return &nr->stats;
 }
 
+static const struct header_ops nr_header_ops = {
+       .create = nr_header,
+       .rebuild= nr_rebuild_header,
+};
+
+
 void nr_setup(struct net_device *dev)
 {
        dev->mtu                = NR_MAX_PACKET_SIZE;
@@ -200,11 +207,10 @@ void nr_setup(struct net_device *dev)
        dev->open               = nr_open;
        dev->stop               = nr_close;
 
-       dev->hard_header        = nr_header;
+       dev->header_ops         = &nr_header_ops;
        dev->hard_header_len    = NR_NETWORK_LEN + NR_TRANSPORT_LEN;
        dev->addr_len           = AX25_ADDR_LEN;
        dev->type               = ARPHRD_NETROM;
-       dev->rebuild_header     = nr_rebuild_header;
        dev->set_mac_address    = nr_set_mac_address;
 
        /* New-style flags. */
index c9ee343c2a6c5d7d4074448a8b87ee234622a3c8..e11000a8e950950cd5a52ece4597c72761dc8d38 100644 (file)
@@ -389,7 +389,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
        skb_reset_network_header(skb);
 
        /* Try to align data part correctly */
-       if (dev->hard_header) {
+       if (dev->header_ops) {
                skb->data -= dev->hard_header_len;
                skb->tail -= dev->hard_header_len;
                if (len < dev->hard_header_len)
@@ -466,7 +466,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev, struct packet
 
        skb->dev = dev;
 
-       if (dev->hard_header) {
+       if (dev->header_ops) {
                /* The device has an explicit notion of ll header,
                   exported to higher levels.
 
@@ -581,7 +581,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
        sk = pt->af_packet_priv;
        po = pkt_sk(sk);
 
-       if (dev->hard_header) {
+       if (dev->header_ops) {
                if (sk->sk_type != SOCK_DGRAM)
                        skb_push(skb, skb->data - skb_mac_header(skb));
                else if (skb->pkt_type == PACKET_OUTGOING) {
index 8d88795dc663497654aeb0eb292fa91680e260c1..1b6741f1d746c547fce948d799ec9298a9bf7b65 100644 (file)
@@ -35,8 +35,9 @@
 #include <net/ax25.h>
 #include <net/rose.h>
 
-static int rose_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
-       void *daddr, void *saddr, unsigned len)
+static int rose_header(struct sk_buff *skb, struct net_device *dev,
+                      unsigned short type,
+                      const void *daddr, const void *saddr, unsigned len)
 {
        unsigned char *buff = skb_push(skb, ROSE_MIN_LEN + 2);
 
@@ -148,6 +149,11 @@ static struct net_device_stats *rose_get_stats(struct net_device *dev)
        return netdev_priv(dev);
 }
 
+static const struct header_ops rose_header_ops = {
+       .create = rose_header,
+       .rebuild= rose_rebuild_header,
+};
+
 void rose_setup(struct net_device *dev)
 {
        dev->mtu                = ROSE_MAX_PACKET_SIZE - 2;
@@ -155,11 +161,10 @@ void rose_setup(struct net_device *dev)
        dev->open               = rose_open;
        dev->stop               = rose_close;
 
-       dev->hard_header        = rose_header;
+       dev->header_ops         = &rose_header_ops;
        dev->hard_header_len    = AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + ROSE_MIN_LEN;
        dev->addr_len           = ROSE_ADDR_LEN;
        dev->type               = ARPHRD_ROSE;
-       dev->rebuild_header     = rose_rebuild_header;
        dev->set_mac_address    = rose_set_mac_address;
 
        /* New-style flags. */
index d13970f3c7b121ddf28c9c6560aae3ef9acbcab1..be57cf317a7f0dfdaae0b09f2504346e6ba107d8 100644 (file)
@@ -249,10 +249,10 @@ __teql_resolve(struct sk_buff *skb, struct sk_buff *skb_res, struct net_device *
        return (skb_res == NULL) ? -EAGAIN : 1;
 }
 
-static __inline__ int
-teql_resolve(struct sk_buff *skb, struct sk_buff *skb_res, struct net_device *dev)
+static inline int teql_resolve(struct sk_buff *skb,
+                              struct sk_buff *skb_res, struct net_device *dev)
 {
-       if (dev->hard_header == NULL ||
+       if (dev->header_ops == NULL ||
            skb->dst == NULL ||
            skb->dst->neighbour == NULL)
                return 0;