aboutsummaryrefslogtreecommitdiff
path: root/net/core/filter.c
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2019-01-23 15:33:21 +0000
committerMark Brown <broonie@kernel.org>2019-01-23 15:33:21 +0000
commitc331a1e462792ad1de0222a666c47be24ba137c2 (patch)
tree16171d08dc8a87da1d93616f1fcfe866900027ca /net/core/filter.c
parentb2ba01d09830fd773891a9a9b62f975fe968f1a8 (diff)
parent8eb445afe1b57a4ecf40c27e93437e9deb79b963 (diff)
Merge branch 'linux-linaro-lsk-v4.14' into linux-linaro-lsk-v4.14-rt
Diffstat (limited to 'net/core/filter.c')
-rw-r--r--net/core/filter.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/net/core/filter.c b/net/core/filter.c
index ad96ec78f7b8..d094b8d7ff1b 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -1714,18 +1714,19 @@ static inline int __bpf_tx_skb(struct net_device *dev, struct sk_buff *skb)
static int __bpf_redirect_no_mac(struct sk_buff *skb, struct net_device *dev,
u32 flags)
{
- /* skb->mac_len is not set on normal egress */
- unsigned int mlen = skb->network_header - skb->mac_header;
+ unsigned int mlen = skb_network_offset(skb);
- __skb_pull(skb, mlen);
+ if (mlen) {
+ __skb_pull(skb, mlen);
- /* At ingress, the mac header has already been pulled once.
- * At egress, skb_pospull_rcsum has to be done in case that
- * the skb is originated from ingress (i.e. a forwarded skb)
- * to ensure that rcsum starts at net header.
- */
- if (!skb_at_tc_ingress(skb))
- skb_postpull_rcsum(skb, skb_mac_header(skb), mlen);
+ /* At ingress, the mac header has already been pulled once.
+ * At egress, skb_pospull_rcsum has to be done in case that
+ * the skb is originated from ingress (i.e. a forwarded skb)
+ * to ensure that rcsum starts at net header.
+ */
+ if (!skb_at_tc_ingress(skb))
+ skb_postpull_rcsum(skb, skb_mac_header(skb), mlen);
+ }
skb_pop_mac_header(skb);
skb_reset_mac_len(skb);
return flags & BPF_F_INGRESS ?