diff options
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r-- | include/linux/netdevice.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index efe7cec111fa..fd30cb545c45 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -268,6 +268,7 @@ struct header_ops { | |||
268 | void (*cache_update)(struct hh_cache *hh, | 268 | void (*cache_update)(struct hh_cache *hh, |
269 | const struct net_device *dev, | 269 | const struct net_device *dev, |
270 | const unsigned char *haddr); | 270 | const unsigned char *haddr); |
271 | bool (*validate)(const char *ll_header, unsigned int len); | ||
271 | }; | 272 | }; |
272 | 273 | ||
273 | /* These flag bits are private to the generic network queueing | 274 | /* These flag bits are private to the generic network queueing |
@@ -1459,8 +1460,7 @@ enum netdev_priv_flags { | |||
1459 | * @dma: DMA channel | 1460 | * @dma: DMA channel |
1460 | * @mtu: Interface MTU value | 1461 | * @mtu: Interface MTU value |
1461 | * @type: Interface hardware type | 1462 | * @type: Interface hardware type |
1462 | * @hard_header_len: Hardware header length, which means that this is the | 1463 | * @hard_header_len: Maximum hardware header length. |
1463 | * minimum size of a packet. | ||
1464 | * | 1464 | * |
1465 | * @needed_headroom: Extra headroom the hardware may need, but not in all | 1465 | * @needed_headroom: Extra headroom the hardware may need, but not in all |
1466 | * cases can this be guaranteed | 1466 | * cases can this be guaranteed |
@@ -2687,6 +2687,24 @@ static inline int dev_parse_header(const struct sk_buff *skb, | |||
2687 | return dev->header_ops->parse(skb, haddr); | 2687 | return dev->header_ops->parse(skb, haddr); |
2688 | } | 2688 | } |
2689 | 2689 | ||
2690 | /* ll_header must have at least hard_header_len allocated */ | ||
2691 | static inline bool dev_validate_header(const struct net_device *dev, | ||
2692 | char *ll_header, int len) | ||
2693 | { | ||
2694 | if (likely(len >= dev->hard_header_len)) | ||
2695 | return true; | ||
2696 | |||
2697 | if (capable(CAP_SYS_RAWIO)) { | ||
2698 | memset(ll_header + len, 0, dev->hard_header_len - len); | ||
2699 | return true; | ||
2700 | } | ||
2701 | |||
2702 | if (dev->header_ops && dev->header_ops->validate) | ||
2703 | return dev->header_ops->validate(ll_header, len); | ||
2704 | |||
2705 | return false; | ||
2706 | } | ||
2707 | |||
2690 | typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len); | 2708 | typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len); |
2691 | int register_gifconf(unsigned int family, gifconf_func_t *gifconf); | 2709 | int register_gifconf(unsigned int family, gifconf_func_t *gifconf); |
2692 | static inline int unregister_gifconf(unsigned int family) | 2710 | static inline int unregister_gifconf(unsigned int family) |