Enable reuse of logic in eth_type_trans for determining packet type.
Showing the changes to include/linux (1 of 2 files). Show all
Unified · Split
| @@ -607,6 +607,31 @@ static inline void eth_hw_addr_gen(struct net_device *dev, const u8 *base_addr, · 606 unmodified lines | ||
| 607 | 607 | eth_hw_addr_set(dev, addr); |
| 608 | 608 | } |
| 609 | 609 | |
| 610 | +/** | |
| 611 | + * eth_skb_pkt_type - Assign packet type if destination address does not match | |
| 612 | + * @skb: Assigned a packet type if address does not match @dev address | |
| 613 | + * @dev: Network device used to compare packet address against | |
| 614 | + * | |
| 615 | + * If the destination MAC address of the packet does not match the network | |
| 616 | + * device address, assign an appropriate packet type. | |
| 617 | + */ | |
| 618 | +static inline void eth_skb_pkt_type(struct sk_buff *skb, | |
| 619 | + const struct net_device *dev) | |
| 620 | +{ | |
| 621 | + const struct ethhdr *eth = eth_hdr(skb); | |
| 622 | + | |
| 623 | + if (unlikely(!ether_addr_equal_64bits(eth->h_dest, dev->dev_addr))) { | |
| 624 | + if (unlikely(is_multicast_ether_addr_64bits(eth->h_dest))) { | |
| 625 | + if (ether_addr_equal_64bits(eth->h_dest, dev->broadcast)) | |
| 626 | + skb->pkt_type = PACKET_BROADCAST; | |
| 627 | + else | |
| 628 | + skb->pkt_type = PACKET_MULTICAST; | |
| 629 | + } else { | |
| 630 | + skb->pkt_type = PACKET_OTHERHOST; | |
| 631 | + } | |
| 632 | + } | |
| 633 | +} | |
| 634 | + | |
| 610 | 635 | /** |
| 611 | 636 | * eth_skb_pad - Pad buffer to mininum number of octets for Ethernet frame |
| 612 | 637 | * @skb: Buffer to pad |