diff options
Diffstat (limited to 'net/ethernet/eth.c')
| -rw-r--r-- | net/ethernet/eth.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index bdeb2f0ace32..ed8a3d49487d 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c | |||
| @@ -75,8 +75,9 @@ __setup("ether=", netdev_boot_setup); | |||
| 75 | * Set the protocol type. For a packet of type ETH_P_802_3 we put the length | 75 | * Set the protocol type. For a packet of type ETH_P_802_3 we put the length |
| 76 | * in here instead. It is up to the 802.2 layer to carry protocol information. | 76 | * in here instead. It is up to the 802.2 layer to carry protocol information. |
| 77 | */ | 77 | */ |
| 78 | int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, | 78 | int eth_header(struct sk_buff *skb, struct net_device *dev, |
| 79 | void *daddr, void *saddr, unsigned len) | 79 | unsigned short type, |
| 80 | const void *daddr, const void *saddr, unsigned len) | ||
| 80 | { | 81 | { |
| 81 | struct ethhdr *eth = (struct ethhdr *)skb_push(skb, ETH_HLEN); | 82 | struct ethhdr *eth = (struct ethhdr *)skb_push(skb, ETH_HLEN); |
| 82 | 83 | ||
| @@ -109,6 +110,7 @@ int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, | |||
| 109 | 110 | ||
| 110 | return -ETH_HLEN; | 111 | return -ETH_HLEN; |
| 111 | } | 112 | } |
| 113 | EXPORT_SYMBOL(eth_header); | ||
| 112 | 114 | ||
| 113 | /** | 115 | /** |
| 114 | * eth_rebuild_header- rebuild the Ethernet MAC header. | 116 | * eth_rebuild_header- rebuild the Ethernet MAC header. |
| @@ -141,6 +143,7 @@ int eth_rebuild_header(struct sk_buff *skb) | |||
| 141 | 143 | ||
| 142 | return 0; | 144 | return 0; |
| 143 | } | 145 | } |
| 146 | EXPORT_SYMBOL(eth_rebuild_header); | ||
| 144 | 147 | ||
| 145 | /** | 148 | /** |
| 146 | * eth_type_trans - determine the packet's protocol ID. | 149 | * eth_type_trans - determine the packet's protocol ID. |
| @@ -207,12 +210,13 @@ EXPORT_SYMBOL(eth_type_trans); | |||
| 207 | * @skb: packet to extract header from | 210 | * @skb: packet to extract header from |
| 208 | * @haddr: destination buffer | 211 | * @haddr: destination buffer |
| 209 | */ | 212 | */ |
| 210 | static int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr) | 213 | int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr) |
| 211 | { | 214 | { |
| 212 | const struct ethhdr *eth = eth_hdr(skb); | 215 | const struct ethhdr *eth = eth_hdr(skb); |
| 213 | memcpy(haddr, eth->h_source, ETH_ALEN); | 216 | memcpy(haddr, eth->h_source, ETH_ALEN); |
| 214 | return ETH_ALEN; | 217 | return ETH_ALEN; |
| 215 | } | 218 | } |
| 219 | EXPORT_SYMBOL(eth_header_parse); | ||
| 216 | 220 | ||
| 217 | /** | 221 | /** |
| 218 | * eth_header_cache - fill cache entry from neighbour | 222 | * 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) | |||
| 220 | * @hh: destination cache entry | 224 | * @hh: destination cache entry |
| 221 | * Create an Ethernet header template from the neighbour. | 225 | * Create an Ethernet header template from the neighbour. |
| 222 | */ | 226 | */ |
| 223 | int eth_header_cache(struct neighbour *neigh, struct hh_cache *hh) | 227 | int eth_header_cache(const struct neighbour *neigh, struct hh_cache *hh) |
| 224 | { | 228 | { |
| 225 | __be16 type = hh->hh_type; | 229 | __be16 type = hh->hh_type; |
| 226 | struct ethhdr *eth; | 230 | struct ethhdr *eth; |
| 227 | struct net_device *dev = neigh->dev; | 231 | const struct net_device *dev = neigh->dev; |
| 228 | 232 | ||
| 229 | eth = (struct ethhdr *) | 233 | eth = (struct ethhdr *) |
| 230 | (((u8 *) hh->hh_data) + (HH_DATA_OFF(sizeof(*eth)))); | 234 | (((u8 *) hh->hh_data) + (HH_DATA_OFF(sizeof(*eth)))); |
| @@ -238,6 +242,7 @@ int eth_header_cache(struct neighbour *neigh, struct hh_cache *hh) | |||
| 238 | hh->hh_len = ETH_HLEN; | 242 | hh->hh_len = ETH_HLEN; |
| 239 | return 0; | 243 | return 0; |
| 240 | } | 244 | } |
| 245 | EXPORT_SYMBOL(eth_header_cache); | ||
| 241 | 246 | ||
| 242 | /** | 247 | /** |
| 243 | * eth_header_cache_update - update cache entry | 248 | * eth_header_cache_update - update cache entry |
| @@ -247,12 +252,14 @@ int eth_header_cache(struct neighbour *neigh, struct hh_cache *hh) | |||
| 247 | * | 252 | * |
| 248 | * Called by Address Resolution module to notify changes in address. | 253 | * Called by Address Resolution module to notify changes in address. |
| 249 | */ | 254 | */ |
| 250 | void eth_header_cache_update(struct hh_cache *hh, struct net_device *dev, | 255 | void eth_header_cache_update(struct hh_cache *hh, |
| 251 | unsigned char *haddr) | 256 | const struct net_device *dev, |
| 257 | const unsigned char *haddr) | ||
| 252 | { | 258 | { |
| 253 | memcpy(((u8 *) hh->hh_data) + HH_DATA_OFF(sizeof(struct ethhdr)), | 259 | memcpy(((u8 *) hh->hh_data) + HH_DATA_OFF(sizeof(struct ethhdr)), |
| 254 | haddr, ETH_ALEN); | 260 | haddr, ETH_ALEN); |
| 255 | } | 261 | } |
| 262 | EXPORT_SYMBOL(eth_header_cache_update); | ||
| 256 | 263 | ||
| 257 | /** | 264 | /** |
| 258 | * eth_mac_addr - set new Ethernet hardware address | 265 | * eth_mac_addr - set new Ethernet hardware address |
| @@ -291,6 +298,14 @@ static int eth_change_mtu(struct net_device *dev, int new_mtu) | |||
| 291 | return 0; | 298 | return 0; |
| 292 | } | 299 | } |
| 293 | 300 | ||
| 301 | const struct header_ops eth_header_ops ____cacheline_aligned = { | ||
| 302 | .create = eth_header, | ||
| 303 | .parse = eth_header_parse, | ||
| 304 | .rebuild = eth_rebuild_header, | ||
| 305 | .cache = eth_header_cache, | ||
| 306 | .cache_update = eth_header_cache_update, | ||
| 307 | }; | ||
| 308 | |||
| 294 | /** | 309 | /** |
| 295 | * ether_setup - setup Ethernet network device | 310 | * ether_setup - setup Ethernet network device |
| 296 | * @dev: network device | 311 | * @dev: network device |
| @@ -298,13 +313,10 @@ static int eth_change_mtu(struct net_device *dev, int new_mtu) | |||
| 298 | */ | 313 | */ |
| 299 | void ether_setup(struct net_device *dev) | 314 | void ether_setup(struct net_device *dev) |
| 300 | { | 315 | { |
| 316 | dev->header_ops = ð_header_ops; | ||
| 317 | |||
| 301 | dev->change_mtu = eth_change_mtu; | 318 | dev->change_mtu = eth_change_mtu; |
| 302 | dev->hard_header = eth_header; | ||
| 303 | dev->rebuild_header = eth_rebuild_header; | ||
| 304 | dev->set_mac_address = eth_mac_addr; | 319 | dev->set_mac_address = eth_mac_addr; |
| 305 | dev->hard_header_cache = eth_header_cache; | ||
| 306 | dev->header_cache_update= eth_header_cache_update; | ||
| 307 | dev->hard_header_parse = eth_header_parse; | ||
| 308 | 320 | ||
| 309 | dev->type = ARPHRD_ETHER; | 321 | dev->type = ARPHRD_ETHER; |
| 310 | dev->hard_header_len = ETH_HLEN; | 322 | dev->hard_header_len = ETH_HLEN; |
