diff options
author | Stephen Hemminger <shemminger@linux-foundation.org> | 2007-10-09 04:40:57 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:52:52 -0400 |
commit | 3b04ddde02cf1b6f14f2697da5c20eca5715017f (patch) | |
tree | 9da1341a5a399a507b5ea6bf5a3047506b8d8f8f /net/ipv4 | |
parent | b95cce3576813ac3f86bafa6b5daaaaf7574b0fe (diff) |
[NET]: Move hardware header operations out of netdevice.
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>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/arp.c | 6 | ||||
-rw-r--r-- | net/ipv4/ip_gre.c | 13 | ||||
-rw-r--r-- | net/ipv4/ip_output.c | 2 |
3 files changed, 14 insertions, 7 deletions
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index 5b24c65b13c6..d8248198bcd7 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c | |||
@@ -253,7 +253,7 @@ static int arp_constructor(struct neighbour *neigh) | |||
253 | neigh->parms = neigh_parms_clone(parms); | 253 | neigh->parms = neigh_parms_clone(parms); |
254 | rcu_read_unlock(); | 254 | rcu_read_unlock(); |
255 | 255 | ||
256 | if (dev->hard_header == NULL) { | 256 | if (!dev->header_ops) { |
257 | neigh->nud_state = NUD_NOARP; | 257 | neigh->nud_state = NUD_NOARP; |
258 | neigh->ops = &arp_direct_ops; | 258 | neigh->ops = &arp_direct_ops; |
259 | neigh->output = neigh->ops->queue_xmit; | 259 | neigh->output = neigh->ops->queue_xmit; |
@@ -310,10 +310,12 @@ static int arp_constructor(struct neighbour *neigh) | |||
310 | neigh->nud_state = NUD_NOARP; | 310 | neigh->nud_state = NUD_NOARP; |
311 | memcpy(neigh->ha, dev->broadcast, dev->addr_len); | 311 | memcpy(neigh->ha, dev->broadcast, dev->addr_len); |
312 | } | 312 | } |
313 | if (dev->hard_header_cache) | 313 | |
314 | if (dev->header_ops->cache) | ||
314 | neigh->ops = &arp_hh_ops; | 315 | neigh->ops = &arp_hh_ops; |
315 | else | 316 | else |
316 | neigh->ops = &arp_generic_ops; | 317 | neigh->ops = &arp_generic_ops; |
318 | |||
317 | if (neigh->nud_state&NUD_VALID) | 319 | if (neigh->nud_state&NUD_VALID) |
318 | neigh->output = neigh->ops->connected_output; | 320 | neigh->output = neigh->ops->connected_output; |
319 | else | 321 | else |
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index ffa9f1c9dcbb..f151900efaf9 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
@@ -684,7 +684,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev) | |||
684 | goto tx_error; | 684 | goto tx_error; |
685 | } | 685 | } |
686 | 686 | ||
687 | if (dev->hard_header) { | 687 | if (dev->header_ops) { |
688 | gre_hlen = 0; | 688 | gre_hlen = 0; |
689 | tiph = (struct iphdr*)skb->data; | 689 | tiph = (struct iphdr*)skb->data; |
690 | } else { | 690 | } else { |
@@ -1063,8 +1063,9 @@ static int ipgre_tunnel_change_mtu(struct net_device *dev, int new_mtu) | |||
1063 | 1063 | ||
1064 | */ | 1064 | */ |
1065 | 1065 | ||
1066 | static int ipgre_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, | 1066 | static int ipgre_header(struct sk_buff *skb, struct net_device *dev, |
1067 | void *daddr, void *saddr, unsigned len) | 1067 | unsigned short type, |
1068 | const void *daddr, const void *saddr, unsigned len) | ||
1068 | { | 1069 | { |
1069 | struct ip_tunnel *t = netdev_priv(dev); | 1070 | struct ip_tunnel *t = netdev_priv(dev); |
1070 | struct iphdr *iph = (struct iphdr *)skb_push(skb, t->hlen); | 1071 | 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 | |||
1091 | return -t->hlen; | 1092 | return -t->hlen; |
1092 | } | 1093 | } |
1093 | 1094 | ||
1095 | static const struct header_ops ipgre_header_ops = { | ||
1096 | .create = ipgre_header, | ||
1097 | }; | ||
1098 | |||
1094 | static int ipgre_open(struct net_device *dev) | 1099 | static int ipgre_open(struct net_device *dev) |
1095 | { | 1100 | { |
1096 | struct ip_tunnel *t = netdev_priv(dev); | 1101 | struct ip_tunnel *t = netdev_priv(dev); |
@@ -1187,7 +1192,7 @@ static int ipgre_tunnel_init(struct net_device *dev) | |||
1187 | if (!iph->saddr) | 1192 | if (!iph->saddr) |
1188 | return -EINVAL; | 1193 | return -EINVAL; |
1189 | dev->flags = IFF_BROADCAST; | 1194 | dev->flags = IFF_BROADCAST; |
1190 | dev->hard_header = ipgre_header; | 1195 | dev->header_ops = &ipgre_header_ops; |
1191 | dev->open = ipgre_open; | 1196 | dev->open = ipgre_open; |
1192 | dev->stop = ipgre_close; | 1197 | dev->stop = ipgre_close; |
1193 | } | 1198 | } |
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 77f67b7cb9bf..699f06781fd8 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c | |||
@@ -169,7 +169,7 @@ static inline int ip_finish_output2(struct sk_buff *skb) | |||
169 | IP_INC_STATS(IPSTATS_MIB_OUTBCASTPKTS); | 169 | IP_INC_STATS(IPSTATS_MIB_OUTBCASTPKTS); |
170 | 170 | ||
171 | /* Be paranoid, rather than too clever. */ | 171 | /* Be paranoid, rather than too clever. */ |
172 | if (unlikely(skb_headroom(skb) < hh_len && dev->hard_header)) { | 172 | if (unlikely(skb_headroom(skb) < hh_len && dev->header_ops)) { |
173 | struct sk_buff *skb2; | 173 | struct sk_buff *skb2; |
174 | 174 | ||
175 | skb2 = skb_realloc_headroom(skb, LL_RESERVED_SPACE(dev)); | 175 | skb2 = skb_realloc_headroom(skb, LL_RESERVED_SPACE(dev)); |