@@ -6220,30 +6220,38 @@ int skb_vlan_pop(struct sk_buff *skb)
}
EXPORT_SYMBOL(skb_vlan_pop);
+static int skb_vlan_flush(struct sk_buff *skb)
+{
+ int offset = skb->data - skb_mac_header(skb);
+ int err;
+
+ if (WARN_ONCE(offset,
+ "skb_vlan_push got skb with skb->data not at mac header (offset %d)\n",
+ offset)) {
+ return -EINVAL;
+ }
+
+ err = __vlan_insert_tag(skb, skb->vlan_proto,
+ skb_vlan_tag_get(skb));
+ if (err)
+ return err;
+
+ skb->protocol = skb->vlan_proto;
+ skb->mac_len += VLAN_HLEN;
+
+ skb_postpush_rcsum(skb, skb->data + (2 * ETH_ALEN), VLAN_HLEN);
+ return 0;
+}
+
/* Push a vlan tag either into hwaccel or into payload (if hwaccel tag present).
* Expects skb->data at mac header.
*/
int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci)
{
if (skb_vlan_tag_present(skb)) {
- int offset = skb->data - skb_mac_header(skb);
- int err;
-
- if (WARN_ONCE(offset,
- "skb_vlan_push got skb with skb->data not at mac header (offset %d)\n",
- offset)) {
- return -EINVAL;
- }
-
- err = __vlan_insert_tag(skb, skb->vlan_proto,
- skb_vlan_tag_get(skb));
+ int err = skb_vlan_flush(skb);
if (err)
return err;
-
- skb->protocol = skb->vlan_proto;
- skb->mac_len += VLAN_HLEN;
-
- skb_postpush_rcsum(skb, skb->data + (2 * ETH_ALEN), VLAN_HLEN);
}
__vlan_hwaccel_put_tag(skb, vlan_proto, vlan_tci);
return 0;
Refactor flushing of the inner vlan in the skb_vlan_push by moving the code into static skb_vlan_flush helper. Signed-off-by: Boris Sukholitko <boris.sukholitko@broadcom.com> --- net/core/skbuff.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-)