History

net: introduce device min_header_len

The stack must not pass packets to device drivers that are shorter than the minimum link layer header length. Previously, packet sockets would drop packets smaller than or equal to dev->hard_header_len, but this has false positives. Zero length payload is used over Ethernet. Other link layer protocols support variable length headers. Support for validation of these protocols removed the min length check for all protocols. Introduce an explicit dev->min_header_len parameter and drop all packets below this value. Initially, set it to non-zero only for Ethernet and loopback. Other protocols can follow in a patch to net-next.

Willem de Bruijn committed 9 years ago

Commit 217e6fa1 parent d7426c63 files · +6 −0Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/netdevice.h+4−0
@@ -1511,6 +1511,7 @@ enum netdev_priv_flags { · 1510 unmodified lines
15111511 * @max_mtu: Interface Maximum MTU value
15121512 * @type: Interface hardware type
15131513 * @hard_header_len: Maximum hardware header length.
1514+ * @min_header_len: Minimum hardware header length
15141515 *
15151516 * @needed_headroom: Extra headroom the hardware may need, but not in all
15161517 * cases can this be guaranteed
@@ -1728,6 +1729,7 @@ struct net_device { · 211 unmodified lines
17281729 unsigned int max_mtu;
17291730 unsigned short type;
17301731 unsigned short hard_header_len;
1732+ unsigned short min_header_len;
17311733
17321734 unsigned short needed_headroom;
17331735 unsigned short needed_tailroom;
@@ -2694,6 +2696,8 @@ static inline bool dev_validate_header(const struct net_device *dev, · 960 unmodified lines
26942696 {
26952697 if (likely(len >= dev->hard_header_len))
26962698 return true;
2699+ if (len < dev->min_header_len)
2700+ return false;
26972701
26982702 if (capable(CAP_SYS_RAWIO)) {
26992703 memset(ll_header + len, 0, dev->hard_header_len - len);