Skip to content

Commit 05e8ef4

Browse files
Pravin B Shelardavem330
authored andcommitted
net: factor out skb_mac_gso_segment() from skb_gso_segment()
This function will be used in next GRE_GSO patch. This patch does not change any functionality. It only exports skb_mac_gso_segment() function. [ Use skb_reset_mac_len() -DaveM ] Signed-off-by: Pravin B Shelar <[email protected]> Acked-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 14bbd6a commit 05e8ef4

File tree

2 files changed

+50
-31
lines changed

2 files changed

+50
-31
lines changed

include/linux/netdevice.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,6 +2671,8 @@ extern void netdev_upper_dev_unlink(struct net_device *dev,
26712671
extern int skb_checksum_help(struct sk_buff *skb);
26722672
extern struct sk_buff *__skb_gso_segment(struct sk_buff *skb,
26732673
netdev_features_t features, bool tx_path);
2674+
extern struct sk_buff *skb_mac_gso_segment(struct sk_buff *skb,
2675+
netdev_features_t features);
26742676

26752677
static inline
26762678
struct sk_buff *skb_gso_segment(struct sk_buff *skb, netdev_features_t features)

net/core/dev.c

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,37 +2327,20 @@ int skb_checksum_help(struct sk_buff *skb)
23272327
}
23282328
EXPORT_SYMBOL(skb_checksum_help);
23292329

2330-
/* openvswitch calls this on rx path, so we need a different check.
2331-
*/
2332-
static inline bool skb_needs_check(struct sk_buff *skb, bool tx_path)
2333-
{
2334-
if (tx_path)
2335-
return skb->ip_summed != CHECKSUM_PARTIAL;
2336-
else
2337-
return skb->ip_summed == CHECKSUM_NONE;
2338-
}
2339-
23402330
/**
2341-
* __skb_gso_segment - Perform segmentation on skb.
2331+
* skb_mac_gso_segment - mac layer segmentation handler.
23422332
* @skb: buffer to segment
23432333
* @features: features for the output path (see dev->features)
2344-
* @tx_path: whether it is called in TX path
2345-
*
2346-
* This function segments the given skb and returns a list of segments.
2347-
*
2348-
* It may return NULL if the skb requires no segmentation. This is
2349-
* only possible when GSO is used for verifying header integrity.
23502334
*/
2351-
struct sk_buff *__skb_gso_segment(struct sk_buff *skb,
2352-
netdev_features_t features, bool tx_path)
2335+
struct sk_buff *skb_mac_gso_segment(struct sk_buff *skb,
2336+
netdev_features_t features)
23532337
{
23542338
struct sk_buff *segs = ERR_PTR(-EPROTONOSUPPORT);
23552339
struct packet_offload *ptype;
23562340
__be16 type = skb->protocol;
2357-
int vlan_depth = ETH_HLEN;
2358-
int err;
23592341

23602342
while (type == htons(ETH_P_8021Q)) {
2343+
int vlan_depth = ETH_HLEN;
23612344
struct vlan_hdr *vh;
23622345

23632346
if (unlikely(!pskb_may_pull(skb, vlan_depth + VLAN_HLEN)))
@@ -2368,22 +2351,14 @@ struct sk_buff *__skb_gso_segment(struct sk_buff *skb,
23682351
vlan_depth += VLAN_HLEN;
23692352
}
23702353

2371-
skb_reset_mac_header(skb);
2372-
skb->mac_len = skb->network_header - skb->mac_header;
23732354
__skb_pull(skb, skb->mac_len);
23742355

2375-
if (unlikely(skb_needs_check(skb, tx_path))) {
2376-
skb_warn_bad_offload(skb);
2377-
2378-
if (skb_header_cloned(skb) &&
2379-
(err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC)))
2380-
return ERR_PTR(err);
2381-
}
2382-
23832356
rcu_read_lock();
23842357
list_for_each_entry_rcu(ptype, &offload_base, list) {
23852358
if (ptype->type == type && ptype->callbacks.gso_segment) {
23862359
if (unlikely(skb->ip_summed != CHECKSUM_PARTIAL)) {
2360+
int err;
2361+
23872362
err = ptype->callbacks.gso_send_check(skb);
23882363
segs = ERR_PTR(err);
23892364
if (err || skb_gso_ok(skb, features))
@@ -2401,6 +2376,48 @@ struct sk_buff *__skb_gso_segment(struct sk_buff *skb,
24012376

24022377
return segs;
24032378
}
2379+
EXPORT_SYMBOL(skb_mac_gso_segment);
2380+
2381+
2382+
/* openvswitch calls this on rx path, so we need a different check.
2383+
*/
2384+
static inline bool skb_needs_check(struct sk_buff *skb, bool tx_path)
2385+
{
2386+
if (tx_path)
2387+
return skb->ip_summed != CHECKSUM_PARTIAL;
2388+
else
2389+
return skb->ip_summed == CHECKSUM_NONE;
2390+
}
2391+
2392+
/**
2393+
* __skb_gso_segment - Perform segmentation on skb.
2394+
* @skb: buffer to segment
2395+
* @features: features for the output path (see dev->features)
2396+
* @tx_path: whether it is called in TX path
2397+
*
2398+
* This function segments the given skb and returns a list of segments.
2399+
*
2400+
* It may return NULL if the skb requires no segmentation. This is
2401+
* only possible when GSO is used for verifying header integrity.
2402+
*/
2403+
struct sk_buff *__skb_gso_segment(struct sk_buff *skb,
2404+
netdev_features_t features, bool tx_path)
2405+
{
2406+
if (unlikely(skb_needs_check(skb, tx_path))) {
2407+
int err;
2408+
2409+
skb_warn_bad_offload(skb);
2410+
2411+
if (skb_header_cloned(skb) &&
2412+
(err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC)))
2413+
return ERR_PTR(err);
2414+
}
2415+
2416+
skb_reset_mac_header(skb);
2417+
skb_reset_mac_len(skb);
2418+
2419+
return skb_mac_gso_segment(skb, features);
2420+
}
24042421
EXPORT_SYMBOL(__skb_gso_segment);
24052422

24062423
/* Take action when hardware reception checksum errors are detected. */

0 commit comments

Comments
 (0)