| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Network Service Header |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) 2017 Red Hat, Inc. -- Jiri Benc <jbenc@redhat.com> |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 8 | | - * published by the Free Software Foundation. |
|---|
| 9 | 6 | */ |
|---|
| 10 | 7 | |
|---|
| 11 | 8 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 80 | 77 | netdev_features_t features) |
|---|
| 81 | 78 | { |
|---|
| 82 | 79 | struct sk_buff *segs = ERR_PTR(-EINVAL); |
|---|
| 80 | + u16 mac_offset = skb->mac_header; |
|---|
| 83 | 81 | unsigned int nsh_len, mac_len; |
|---|
| 84 | 82 | __be16 proto; |
|---|
| 85 | | - int nhoff; |
|---|
| 86 | 83 | |
|---|
| 87 | 84 | skb_reset_network_header(skb); |
|---|
| 88 | 85 | |
|---|
| 89 | | - nhoff = skb->network_header - skb->mac_header; |
|---|
| 90 | 86 | mac_len = skb->mac_len; |
|---|
| 91 | 87 | |
|---|
| 92 | 88 | if (unlikely(!pskb_may_pull(skb, NSH_BASE_HDR_LEN))) |
|---|
| .. | .. |
|---|
| 111 | 107 | segs = skb_mac_gso_segment(skb, features); |
|---|
| 112 | 108 | if (IS_ERR_OR_NULL(segs)) { |
|---|
| 113 | 109 | skb_gso_error_unwind(skb, htons(ETH_P_NSH), nsh_len, |
|---|
| 114 | | - skb->network_header - nhoff, |
|---|
| 115 | | - mac_len); |
|---|
| 110 | + mac_offset, mac_len); |
|---|
| 116 | 111 | goto out; |
|---|
| 117 | 112 | } |
|---|
| 118 | 113 | |
|---|
| 119 | 114 | for (skb = segs; skb; skb = skb->next) { |
|---|
| 120 | 115 | skb->protocol = htons(ETH_P_NSH); |
|---|
| 121 | 116 | __skb_push(skb, nsh_len); |
|---|
| 122 | | - skb_set_mac_header(skb, -nhoff); |
|---|
| 117 | + skb->mac_header = mac_offset; |
|---|
| 123 | 118 | skb->network_header = skb->mac_header + mac_len; |
|---|
| 124 | 119 | skb->mac_len = mac_len; |
|---|
| 125 | 120 | } |
|---|