From 0c0c3b19e4556aec2b561f2983b6b30c18a4472f Mon Sep 17 00:00:00 2001 From: Subash Abhinov Kasiviswanathan Date: Tue, 29 Aug 2017 22:44:17 -0600 Subject: [PATCH 1/2] net: arp: Add support for raw IP device Define the raw IP type. This is needed for raw IP net devices like rmnet. Signed-off-by: Subash Abhinov Kasiviswanathan Signed-off-by: David S. Miller Signed-off-by: Jackeagle --- include/uapi/linux/if_arp.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/if_arp.h b/include/uapi/linux/if_arp.h index 85e29f151403..5f2a3d2ea549 100644 --- a/include/uapi/linux/if_arp.h +++ b/include/uapi/linux/if_arp.h @@ -59,6 +59,7 @@ #define ARPHRD_LAPB 516 /* LAPB */ #define ARPHRD_DDCMP 517 /* Digital's DDCMP protocol */ #define ARPHRD_RAWHDLC 518 /* Raw HDLC */ +#define ARPHRD_RAWIP 519 /* Raw IP */ #define ARPHRD_PUREIP 520 /* PURE IP */ #define ARPHRD_TUNNEL 768 /* IPIP tunnel */ -- GitLab From 3a196c92cf487bfc990ddcff2700463a0bf8cff2 Mon Sep 17 00:00:00 2001 From: Rocco Yue Date: Wed, 27 Jan 2021 09:20:10 +0800 Subject: [PATCH 2/2] [BACKPORT]: clatd: use rawip for ebpf ingress/egress clatd rawip ebpf prog translate ipv4 or ipv6 packet in TC ingress and egress. change ccmni dev->type to ARPHRD_RAWIP. After the ipv6 packet received from ccmnix passes through sw-gro, skb->mac_len becomes to 14. Then before run sched_cls_ingress_clat_rawip() eBPF program, the skb->data pointer will be offset according to skb->mac_len. This will cause the clat_rawip_ebpf program to fail to parse the ip header normally. therefore, we need to change skb mac_len to 0. MTK-Commit-Id: 3aa567ae9572a93eec636ded5327b975a8d13964 Change-Id: I229241ff6ff9af81552073728693759c65369c5f Signed-off-by: Rocco Yue CR-Id: ALPS05517013 Feature: IPv6 over MD [@Jackeagle]: Adapt patch to alps kernel-4.9 from alps kernel-4.14 Change-Id: I3562e5a4d0c1f051596e570954d5c7e70e78bd24 Signed-off-by: Jackeagle --- drivers/misc/mediatek/ccmni/ccmni.c | 2 +- net/ipv6/addrconf.c | 4 ++-- net/sched/cls_bpf.c | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/misc/mediatek/ccmni/ccmni.c b/drivers/misc/mediatek/ccmni/ccmni.c index ebb8a9c5bfcc..c0674aba4a97 100644 --- a/drivers/misc/mediatek/ccmni/ccmni.c +++ b/drivers/misc/mediatek/ccmni/ccmni.c @@ -1099,7 +1099,7 @@ static int ccmni_init(int md_id, struct ccmni_ccci_ops *ccci_info) ccmni_dev_init(md_id, dev); /* used to support auto add ipv6 mroute */ - dev->type = ARPHRD_PUREIP; + dev->type = ARPHRD_RAWIP; sprintf(dev->name, "%s%d", ctlb->ccci_ops->name, i); diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 4b0eac40e368..5b852136b585 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -3230,7 +3230,7 @@ static void addrconf_dev_config(struct net_device *dev) (dev->type != ARPHRD_TUNNEL6) && (dev->type != ARPHRD_6LOWPAN) && (dev->type != ARPHRD_NONE) && - (dev->type != ARPHRD_PUREIP)) { + (dev->type != ARPHRD_RAWIP)) { /* Alas, we support only Ethernet autoconfiguration. */ idev = __in6_dev_get(dev); if (!IS_ERR_OR_NULL(idev) && dev->flags & IFF_UP && @@ -3244,7 +3244,7 @@ static void addrconf_dev_config(struct net_device *dev) return; /*mobile device doesn't need auto-linklocal addr */ - if (dev->type == ARPHRD_PUREIP) + if (dev->type == ARPHRD_RAWIP) return; /* this device type has no EUI support */ diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c index 0a47ba5e6109..0f964f1e4da5 100644 --- a/net/sched/cls_bpf.c +++ b/net/sched/cls_bpf.c @@ -99,6 +99,8 @@ static int cls_bpf_classify(struct sk_buff *skb, const struct tcf_proto *tp, if (tc_skip_sw(prog->gen_flags)) { filter_res = prog->exts_integrated ? TC_ACT_UNSPEC : 0; } else if (at_ingress) { + if ((strncmp(skb->dev->name, "ccmni", 2) == 0)) + skb->mac_len = 0; /* It is safe to push/pull even if skb_shared() */ __skb_push(skb, skb->mac_len); bpf_compute_data_end(skb); -- GitLab