eth.c (3cbf4ffba5eeec60f82868a5facc1962d8a44d00) eth.c (c43f1255b866b423d2381f77eaa2cbc64a9c49aa)
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Ethernet-type device handling.
7 *
8 * Version: @(#)eth.c 1.0.7 05/25/93

--- 105 unchanged lines hidden (view full) ---

114 }
115
116 return -ETH_HLEN;
117}
118EXPORT_SYMBOL(eth_header);
119
120/**
121 * eth_get_headlen - determine the length of header for an ethernet frame
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * Ethernet-type device handling.
7 *
8 * Version: @(#)eth.c 1.0.7 05/25/93

--- 105 unchanged lines hidden (view full) ---

114 }
115
116 return -ETH_HLEN;
117}
118EXPORT_SYMBOL(eth_header);
119
120/**
121 * eth_get_headlen - determine the length of header for an ethernet frame
122 * @dev: pointer to network device
122 * @data: pointer to start of frame
123 * @len: total length of frame
124 *
125 * Make a best effort attempt to pull the length for all of the headers for
126 * a given frame in a linear buffer.
127 */
123 * @data: pointer to start of frame
124 * @len: total length of frame
125 *
126 * Make a best effort attempt to pull the length for all of the headers for
127 * a given frame in a linear buffer.
128 */
128u32 eth_get_headlen(void *data, unsigned int len)
129u32 eth_get_headlen(const struct net_device *dev, void *data, unsigned int len)
129{
130 const unsigned int flags = FLOW_DISSECTOR_F_PARSE_1ST_FRAG;
131 const struct ethhdr *eth = (const struct ethhdr *)data;
132 struct flow_keys_basic keys;
133
134 /* this should never happen, but better safe than sorry */
135 if (unlikely(len < sizeof(*eth)))
136 return len;
137
138 /* parse any remaining L2/L3 headers, check for L4 */
130{
131 const unsigned int flags = FLOW_DISSECTOR_F_PARSE_1ST_FRAG;
132 const struct ethhdr *eth = (const struct ethhdr *)data;
133 struct flow_keys_basic keys;
134
135 /* this should never happen, but better safe than sorry */
136 if (unlikely(len < sizeof(*eth)))
137 return len;
138
139 /* parse any remaining L2/L3 headers, check for L4 */
139 if (!skb_flow_dissect_flow_keys_basic(NULL, NULL, &keys, data,
140 if (!skb_flow_dissect_flow_keys_basic(dev_net(dev), NULL, &keys, data,
140 eth->h_proto, sizeof(*eth),
141 len, flags))
142 return max_t(u32, keys.control.thoff, sizeof(*eth));
143
144 /* parse for any L4 headers */
145 return min_t(u32, __skb_get_poff(NULL, data, &keys, len), len);
146}
147EXPORT_SYMBOL(eth_get_headlen);

--- 457 unchanged lines hidden ---
141 eth->h_proto, sizeof(*eth),
142 len, flags))
143 return max_t(u32, keys.control.thoff, sizeof(*eth));
144
145 /* parse for any L4 headers */
146 return min_t(u32, __skb_get_poff(NULL, data, &keys, len), len);
147}
148EXPORT_SYMBOL(eth_get_headlen);

--- 457 unchanged lines hidden ---