From patchwork Wed Feb 3 07:07:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Bonn X-Patchwork-Id: 12063565 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8260DC433E9 for ; Wed, 3 Feb 2021 07:09:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2CE8C64F60 for ; Wed, 3 Feb 2021 07:09:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232120AbhBCHI7 (ORCPT ); Wed, 3 Feb 2021 02:08:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231755AbhBCHIv (ORCPT ); Wed, 3 Feb 2021 02:08:51 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF984C06174A for ; Tue, 2 Feb 2021 23:08:10 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id h7so31809259lfc.6 for ; Tue, 02 Feb 2021 23:08:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=norrbonn-se.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g1SB2FtrlmzNDA9rqmhIQqmpt3slQ/X5MLqAKGKD8V8=; b=OFihNwBgxTKQ+5gO3S7NV5AzF19vrwYLJszqylBYv+vLGiCnwCH7h62cGdfEWoMlEn 1+i1o4b4+BsOUlx/5feitu75nWCTVVieDq4Ji74UqiF0vHuEDfuiNnbL1qlD7o0+YqWO JXpyGROjdhC5jqaAjOckRr3of8zGsBycI6TyYFH2GLeXodOfje5ZPeYaEG1+SS/ecHHT Rpb5Bp13D5azc1pn4OHuytPWL0NJxU9fd5KB1RUr3MUvI01/KngzVvC8/d/55gMqttdq oWFzfMaW1ph6qPkm3wSpBvg/5u6Wu9WFG+M4HOTr/2G+lePI7wXiUKGHopf3q6eti4ca 7TSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g1SB2FtrlmzNDA9rqmhIQqmpt3slQ/X5MLqAKGKD8V8=; b=c70Ebu5LB/Ut5FiIvth8Erown5LQbD1VFlmB/mJGJoYtbWEtbcc61X10XBK0xE52UW 0b9kkIcvZN+2I7i8DGMhi+HljO5WlbQMb/P91G1fDSzl1HFkNZcWbmgFPTDJQsDoIiAm qK4RO4v8xH9H965c3XKr40UjidudqVHtgFmANb0r/0P4HpzP0YI8rtWbacvQZHnVlu0h w7SfgsUHw85y0HfZ7xq0Iqa0G05MT23p91L+nLD9BtpzD2VY+/xeMrm7H1qqSHoXUg/T d/9sz5VqBlfF9Fauz+dGTphX7Hz6pf0XmCV007Rqa5qLZodez3E63d7VYfqSTEQrIoS4 hMLg== X-Gm-Message-State: AOAM5307nqlC2UCUwL5hePJpI+8+6sEkbNHUAsYoEwgagUmVQLgCYaN1 0DY0hse7UrvWK0R48GI2INQV/g== X-Google-Smtp-Source: ABdhPJyX4NY9FbRNI9vcoI9Nc5WaFy0BVQI5Va5KGwsnrEXhcRNDD8KgiaEIJA60/D5fCxZWbtYrwg== X-Received: by 2002:a05:6512:1311:: with SMTP id x17mr977712lfu.307.1612336089077; Tue, 02 Feb 2021 23:08:09 -0800 (PST) Received: from mimer.emblasoft.lan (h-137-65.A159.priv.bahnhof.se. [81.170.137.65]) by smtp.gmail.com with ESMTPSA id d3sm147367lfg.122.2021.02.02.23.08.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 23:08:08 -0800 (PST) From: Jonas Bonn To: laforge@gnumonks.org, kuba@kernel.org, netdev@vger.kernel.org, pablo@netfilter.org Cc: Jonas Bonn Subject: [PATCH net-next v2 1/7] Revert "GTP: add support for flow based tunneling API" Date: Wed, 3 Feb 2021 08:07:59 +0100 Message-Id: <20210203070805.281321-2-jonas@norrbonn.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210203070805.281321-1-jonas@norrbonn.se> References: <20210202065159.227049-1-jonas@norrbonn.se> <20210203070805.281321-1-jonas@norrbonn.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This reverts commit 9ab7e76aefc97a9aa664accb59d6e8dc5e52514a. This patch was committed without maintainer approval and despite a number of unaddressed concerns from review. There are several issues that impede the acceptance of this patch and that make a reversion of this particular instance of these changes the best way forward: i) the patch contains several logically separate changes that would be better served as smaller patches (for review purposes) ii) functionality like the handling of end markers has been introduced without further explanation iii) symmetry between the handling of GTPv0 and GTPv1 has been unnecessarily broken iv) the patchset produces 'broken' packets when extension headers are included v) there are no available userspace tools to allow for testing this functionality vi) there is an unaddressed Coverity report against the patch concering memory leakage vii) most importantly, the patch contains a large amount of superfluous churn that impedes other ongoing work with this driver This patch will be reworked into a series that aligns with other ongoing work and facilitates review. Signed-off-by: Jonas Bonn Acked-by: Harald Welte --- drivers/net/gtp.c | 527 ++++++++--------------------- include/uapi/linux/gtp.h | 12 - include/uapi/linux/if_link.h | 1 - include/uapi/linux/if_tunnel.h | 1 - tools/include/uapi/linux/if_link.h | 1 - 5 files changed, 144 insertions(+), 398 deletions(-) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index 851364314ecc..4c04e271f184 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -21,7 +21,6 @@ #include #include -#include #include #include #include @@ -74,9 +73,6 @@ struct gtp_dev { unsigned int hash_size; struct hlist_head *tid_hash; struct hlist_head *addr_hash; - /* Used by LWT tunnel. */ - bool collect_md; - struct socket *collect_md_sock; }; static unsigned int gtp_net_id __read_mostly; @@ -183,121 +179,33 @@ static bool gtp_check_ms(struct sk_buff *skb, struct pdp_ctx *pctx, return false; } -static int gtp_set_tun_dst(struct gtp_dev *gtp, struct sk_buff *skb, - unsigned int hdrlen, u8 gtp_version, - __be64 tid, u8 flags) +static int gtp_rx(struct pdp_ctx *pctx, struct sk_buff *skb, + unsigned int hdrlen, unsigned int role) { - struct metadata_dst *tun_dst; - int opts_len = 0; - - if (unlikely(flags & GTP1_F_MASK)) - opts_len = sizeof(struct gtpu_metadata); - - tun_dst = udp_tun_rx_dst(skb, gtp->sk1u->sk_family, TUNNEL_KEY, tid, opts_len); - if (!tun_dst) { - netdev_dbg(gtp->dev, "Failed to allocate tun_dst"); - goto err; + if (!gtp_check_ms(skb, pctx, hdrlen, role)) { + netdev_dbg(pctx->dev, "No PDP ctx for this MS\n"); + return 1; } - netdev_dbg(gtp->dev, "attaching metadata_dst to skb, gtp ver %d hdrlen %d\n", - gtp_version, hdrlen); - if (unlikely(opts_len)) { - struct gtpu_metadata *opts; - struct gtp1_header *gtp1; - - opts = ip_tunnel_info_opts(&tun_dst->u.tun_info); - gtp1 = (struct gtp1_header *)(skb->data + sizeof(struct udphdr)); - opts->ver = GTP_METADATA_V1; - opts->flags = gtp1->flags; - opts->type = gtp1->type; - netdev_dbg(gtp->dev, "recved control pkt: flag %x type: %d\n", - opts->flags, opts->type); - tun_dst->u.tun_info.key.tun_flags |= TUNNEL_GTPU_OPT; - tun_dst->u.tun_info.options_len = opts_len; - skb->protocol = htons(0xffff); /* Unknown */ - } /* Get rid of the GTP + UDP headers. */ if (iptunnel_pull_header(skb, hdrlen, skb->protocol, - !net_eq(sock_net(gtp->sk1u), dev_net(gtp->dev)))) { - gtp->dev->stats.rx_length_errors++; - goto err; - } - - skb_dst_set(skb, &tun_dst->dst); - return 0; -err: - return -1; -} - -static int gtp_rx(struct gtp_dev *gtp, struct sk_buff *skb, - unsigned int hdrlen, u8 gtp_version, unsigned int role, - __be64 tid, u8 flags, u8 type) -{ - if (ip_tunnel_collect_metadata() || gtp->collect_md) { - int err; - - err = gtp_set_tun_dst(gtp, skb, hdrlen, gtp_version, tid, flags); - if (err) - goto err; - } else { - struct pdp_ctx *pctx; - - if (flags & GTP1_F_MASK) - hdrlen += 4; - - if (type != GTP_TPDU) - return 1; + !net_eq(sock_net(pctx->sk), dev_net(pctx->dev)))) + return -1; - if (gtp_version == GTP_V0) - pctx = gtp0_pdp_find(gtp, be64_to_cpu(tid)); - else - pctx = gtp1_pdp_find(gtp, be64_to_cpu(tid)); - if (!pctx) { - netdev_dbg(gtp->dev, "No PDP ctx to decap skb=%p\n", skb); - return 1; - } - - if (!gtp_check_ms(skb, pctx, hdrlen, role)) { - netdev_dbg(pctx->dev, "No PDP ctx for this MS\n"); - return 1; - } - /* Get rid of the GTP + UDP headers. */ - if (iptunnel_pull_header(skb, hdrlen, skb->protocol, - !net_eq(sock_net(pctx->sk), dev_net(gtp->dev)))) { - gtp->dev->stats.rx_length_errors++; - goto err; - } - } - netdev_dbg(gtp->dev, "forwarding packet from GGSN to uplink\n"); + netdev_dbg(pctx->dev, "forwarding packet from GGSN to uplink\n"); /* Now that the UDP and the GTP header have been removed, set up the * new network header. This is required by the upper layer to * calculate the transport header. */ skb_reset_network_header(skb); - if (pskb_may_pull(skb, sizeof(struct iphdr))) { - struct iphdr *iph; - - iph = ip_hdr(skb); - if (iph->version == 4) { - netdev_dbg(gtp->dev, "inner pkt: ipv4"); - skb->protocol = htons(ETH_P_IP); - } else if (iph->version == 6) { - netdev_dbg(gtp->dev, "inner pkt: ipv6"); - skb->protocol = htons(ETH_P_IPV6); - } else { - netdev_dbg(gtp->dev, "inner pkt error: Unknown type"); - } - } - skb->dev = gtp->dev; - dev_sw_netstats_rx_add(gtp->dev, skb->len); + skb->dev = pctx->dev; + + dev_sw_netstats_rx_add(pctx->dev, skb->len); + netif_rx(skb); return 0; - -err: - gtp->dev->stats.rx_dropped++; - return -1; } /* 1 means pass up to the stack, -1 means drop and 0 means decapsulated. */ @@ -306,6 +214,7 @@ static int gtp0_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb) unsigned int hdrlen = sizeof(struct udphdr) + sizeof(struct gtp0_header); struct gtp0_header *gtp0; + struct pdp_ctx *pctx; if (!pskb_may_pull(skb, hdrlen)) return -1; @@ -315,7 +224,16 @@ static int gtp0_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb) if ((gtp0->flags >> 5) != GTP_V0) return 1; - return gtp_rx(gtp, skb, hdrlen, GTP_V0, gtp->role, gtp0->tid, gtp0->flags, gtp0->type); + if (gtp0->type != GTP_TPDU) + return 1; + + pctx = gtp0_pdp_find(gtp, be64_to_cpu(gtp0->tid)); + if (!pctx) { + netdev_dbg(gtp->dev, "No PDP ctx to decap skb=%p\n", skb); + return 1; + } + + return gtp_rx(pctx, skb, hdrlen, gtp->role); } static int gtp1u_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb) @@ -323,30 +241,41 @@ static int gtp1u_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb) unsigned int hdrlen = sizeof(struct udphdr) + sizeof(struct gtp1_header); struct gtp1_header *gtp1; + struct pdp_ctx *pctx; if (!pskb_may_pull(skb, hdrlen)) return -1; gtp1 = (struct gtp1_header *)(skb->data + sizeof(struct udphdr)); - netdev_dbg(gtp->dev, "GTPv1 recv: flags %x\n", gtp1->flags); if ((gtp1->flags >> 5) != GTP_V1) return 1; + if (gtp1->type != GTP_TPDU) + return 1; + /* From 29.060: "This field shall be present if and only if any one or * more of the S, PN and E flags are set.". * * If any of the bit is set, then the remaining ones also have to be * set. */ + if (gtp1->flags & GTP1_F_MASK) + hdrlen += 4; + /* Make sure the header is larger enough, including extensions. */ if (!pskb_may_pull(skb, hdrlen)) return -1; gtp1 = (struct gtp1_header *)(skb->data + sizeof(struct udphdr)); - return gtp_rx(gtp, skb, hdrlen, GTP_V1, gtp->role, - key32_to_tunnel_id(gtp1->tid), gtp1->flags, gtp1->type); + pctx = gtp1_pdp_find(gtp, ntohl(gtp1->tid)); + if (!pctx) { + netdev_dbg(gtp->dev, "No PDP ctx to decap skb=%p\n", skb); + return 1; + } + + return gtp_rx(pctx, skb, hdrlen, gtp->role); } static void __gtp_encap_destroy(struct sock *sk) @@ -386,11 +315,6 @@ static void gtp_encap_disable(struct gtp_dev *gtp) { gtp_encap_disable_sock(gtp->sk0); gtp_encap_disable_sock(gtp->sk1u); - if (gtp->collect_md_sock) { - udp_tunnel_sock_release(gtp->collect_md_sock); - gtp->collect_md_sock = NULL; - netdev_dbg(gtp->dev, "GTP socket released.\n"); - } } /* UDP encapsulation receive handler. See net/ipv4/udp.c. @@ -405,8 +329,7 @@ static int gtp_encap_recv(struct sock *sk, struct sk_buff *skb) if (!gtp) return 1; - netdev_dbg(gtp->dev, "encap_recv sk=%p type %d\n", - sk, udp_sk(sk)->encap_type); + netdev_dbg(gtp->dev, "encap_recv sk=%p\n", sk); switch (udp_sk(sk)->encap_type) { case UDP_ENCAP_GTP0: @@ -460,13 +383,12 @@ static void gtp_dev_uninit(struct net_device *dev) static struct rtable *ip4_route_output_gtp(struct flowi4 *fl4, const struct sock *sk, - __be32 daddr, - __be32 saddr) + __be32 daddr) { memset(fl4, 0, sizeof(*fl4)); fl4->flowi4_oif = sk->sk_bound_dev_if; fl4->daddr = daddr; - fl4->saddr = saddr; + fl4->saddr = inet_sk(sk)->inet_saddr; fl4->flowi4_tos = RT_CONN_FLAGS(sk); fl4->flowi4_proto = sk->sk_protocol; @@ -490,7 +412,7 @@ static inline void gtp0_push_header(struct sk_buff *skb, struct pdp_ctx *pctx) gtp0->tid = cpu_to_be64(pctx->u.v0.tid); } -static inline void gtp1_push_header(struct sk_buff *skb, __be32 tid) +static inline void gtp1_push_header(struct sk_buff *skb, struct pdp_ctx *pctx) { int payload_len = skb->len; struct gtp1_header *gtp1; @@ -506,63 +428,46 @@ static inline void gtp1_push_header(struct sk_buff *skb, __be32 tid) gtp1->flags = 0x30; /* v1, GTP-non-prime. */ gtp1->type = GTP_TPDU; gtp1->length = htons(payload_len); - gtp1->tid = tid; + gtp1->tid = htonl(pctx->u.v1.o_tei); /* TODO: Suppport for extension header, sequence number and N-PDU. * Update the length field if any of them is available. */ } -static inline int gtp1_push_control_header(struct sk_buff *skb, - __be32 tid, - struct gtpu_metadata *opts, - struct net_device *dev) -{ - struct gtp1_header *gtp1c; - int payload_len; - - if (opts->ver != GTP_METADATA_V1) - return -ENOENT; +struct gtp_pktinfo { + struct sock *sk; + struct iphdr *iph; + struct flowi4 fl4; + struct rtable *rt; + struct pdp_ctx *pctx; + struct net_device *dev; + __be16 gtph_port; +}; - if (opts->type == 0xFE) { - /* for end marker ignore skb data. */ - netdev_dbg(dev, "xmit pkt with null data"); - pskb_trim(skb, 0); +static void gtp_push_header(struct sk_buff *skb, struct gtp_pktinfo *pktinfo) +{ + switch (pktinfo->pctx->gtp_version) { + case GTP_V0: + pktinfo->gtph_port = htons(GTP0_PORT); + gtp0_push_header(skb, pktinfo->pctx); + break; + case GTP_V1: + pktinfo->gtph_port = htons(GTP1U_PORT); + gtp1_push_header(skb, pktinfo->pctx); + break; } - if (skb_cow_head(skb, sizeof(*gtp1c)) < 0) - return -ENOMEM; - - payload_len = skb->len; - - gtp1c = skb_push(skb, sizeof(*gtp1c)); - - gtp1c->flags = opts->flags; - gtp1c->type = opts->type; - gtp1c->length = htons(payload_len); - gtp1c->tid = tid; - netdev_dbg(dev, "xmit control pkt: ver %d flags %x type %x pkt len %d tid %x", - opts->ver, opts->flags, opts->type, skb->len, tid); - return 0; } -struct gtp_pktinfo { - struct sock *sk; - __u8 tos; - struct flowi4 fl4; - struct rtable *rt; - struct net_device *dev; - __be16 gtph_port; -}; - static inline void gtp_set_pktinfo_ipv4(struct gtp_pktinfo *pktinfo, - struct sock *sk, - __u8 tos, - struct rtable *rt, + struct sock *sk, struct iphdr *iph, + struct pdp_ctx *pctx, struct rtable *rt, struct flowi4 *fl4, struct net_device *dev) { pktinfo->sk = sk; - pktinfo->tos = tos; + pktinfo->iph = iph; + pktinfo->pctx = pctx; pktinfo->rt = rt; pktinfo->fl4 = *fl4; pktinfo->dev = dev; @@ -572,99 +477,40 @@ static int gtp_build_skb_ip4(struct sk_buff *skb, struct net_device *dev, struct gtp_pktinfo *pktinfo) { struct gtp_dev *gtp = netdev_priv(dev); - struct gtpu_metadata *opts = NULL; - struct sock *sk = NULL; struct pdp_ctx *pctx; struct rtable *rt; struct flowi4 fl4; - u8 gtp_version; - __be16 df = 0; - __be32 tun_id; - __be32 daddr; - __be32 saddr; - __u8 tos; + struct iphdr *iph; + __be16 df; int mtu; - if (gtp->collect_md) { - /* LWT GTP1U encap */ - struct ip_tunnel_info *info = NULL; - - info = skb_tunnel_info(skb); - if (!info) { - netdev_dbg(dev, "missing tunnel info"); - return -ENOENT; - } - if (info->key.tp_dst && ntohs(info->key.tp_dst) != GTP1U_PORT) { - netdev_dbg(dev, "unexpected GTP dst port: %d", ntohs(info->key.tp_dst)); - return -EOPNOTSUPP; - } - pctx = NULL; - gtp_version = GTP_V1; - tun_id = tunnel_id_to_key32(info->key.tun_id); - daddr = info->key.u.ipv4.dst; - saddr = info->key.u.ipv4.src; - sk = gtp->sk1u; - if (!sk) { - netdev_dbg(dev, "missing tunnel sock"); - return -EOPNOTSUPP; - } - tos = info->key.tos; - if (info->key.tun_flags & TUNNEL_DONT_FRAGMENT) - df = htons(IP_DF); - - if (info->options_len != 0) { - if (info->key.tun_flags & TUNNEL_GTPU_OPT) { - opts = ip_tunnel_info_opts(info); - } else { - netdev_dbg(dev, "missing tunnel metadata for control pkt"); - return -EOPNOTSUPP; - } - } - netdev_dbg(dev, "flow-based GTP1U encap: tunnel id %d\n", - be32_to_cpu(tun_id)); - } else { - struct iphdr *iph; - - if (ntohs(skb->protocol) != ETH_P_IP) - return -EOPNOTSUPP; - - iph = ip_hdr(skb); - - /* Read the IP destination address and resolve the PDP context. - * Prepend PDP header with TEI/TID from PDP ctx. - */ - if (gtp->role == GTP_ROLE_SGSN) - pctx = ipv4_pdp_find(gtp, iph->saddr); - else - pctx = ipv4_pdp_find(gtp, iph->daddr); + /* Read the IP destination address and resolve the PDP context. + * Prepend PDP header with TEI/TID from PDP ctx. + */ + iph = ip_hdr(skb); + if (gtp->role == GTP_ROLE_SGSN) + pctx = ipv4_pdp_find(gtp, iph->saddr); + else + pctx = ipv4_pdp_find(gtp, iph->daddr); - if (!pctx) { - netdev_dbg(dev, "no PDP ctx found for %pI4, skip\n", - &iph->daddr); - return -ENOENT; - } - sk = pctx->sk; - netdev_dbg(dev, "found PDP context %p\n", pctx); - - gtp_version = pctx->gtp_version; - tun_id = htonl(pctx->u.v1.o_tei); - daddr = pctx->peer_addr_ip4.s_addr; - saddr = inet_sk(sk)->inet_saddr; - tos = iph->tos; - df = iph->frag_off; - netdev_dbg(dev, "gtp -> IP src: %pI4 dst: %pI4\n", - &iph->saddr, &iph->daddr); + if (!pctx) { + netdev_dbg(dev, "no PDP ctx found for %pI4, skip\n", + &iph->daddr); + return -ENOENT; } + netdev_dbg(dev, "found PDP context %p\n", pctx); - rt = ip4_route_output_gtp(&fl4, sk, daddr, saddr); + rt = ip4_route_output_gtp(&fl4, pctx->sk, pctx->peer_addr_ip4.s_addr); if (IS_ERR(rt)) { - netdev_dbg(dev, "no route to SSGN %pI4\n", &daddr); + netdev_dbg(dev, "no route to SSGN %pI4\n", + &pctx->peer_addr_ip4.s_addr); dev->stats.tx_carrier_errors++; goto err; } if (rt->dst.dev == dev) { - netdev_dbg(dev, "circular route to SSGN %pI4\n", &daddr); + netdev_dbg(dev, "circular route to SSGN %pI4\n", + &pctx->peer_addr_ip4.s_addr); dev->stats.collisions++; goto err_rt; } @@ -672,10 +518,11 @@ static int gtp_build_skb_ip4(struct sk_buff *skb, struct net_device *dev, skb_dst_drop(skb); /* This is similar to tnl_update_pmtu(). */ + df = iph->frag_off; if (df) { mtu = dst_mtu(&rt->dst) - dev->hard_header_len - sizeof(struct iphdr) - sizeof(struct udphdr); - switch (gtp_version) { + switch (pctx->gtp_version) { case GTP_V0: mtu -= sizeof(struct gtp0_header); break; @@ -689,38 +536,17 @@ static int gtp_build_skb_ip4(struct sk_buff *skb, struct net_device *dev, rt->dst.ops->update_pmtu(&rt->dst, NULL, skb, mtu, false); - if (!skb_is_gso(skb) && (df & htons(IP_DF)) && mtu < skb->len) { - netdev_dbg(dev, "packet too big, fragmentation needed"); + if (!skb_is_gso(skb) && (iph->frag_off & htons(IP_DF)) && + mtu < ntohs(iph->tot_len)) { + netdev_dbg(dev, "packet too big, fragmentation needed\n"); memset(IPCB(skb), 0, sizeof(*IPCB(skb))); icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu)); goto err_rt; } - gtp_set_pktinfo_ipv4(pktinfo, sk, tos, rt, &fl4, dev); - - if (unlikely(opts)) { - int err; - - pktinfo->gtph_port = htons(GTP1U_PORT); - err = gtp1_push_control_header(skb, tun_id, opts, dev); - if (err) { - netdev_info(dev, "cntr pkt error %d", err); - goto err_rt; - } - return 0; - } - - switch (gtp_version) { - case GTP_V0: - pktinfo->gtph_port = htons(GTP0_PORT); - gtp0_push_header(skb, pctx); - break; - case GTP_V1: - pktinfo->gtph_port = htons(GTP1U_PORT); - gtp1_push_header(skb, tun_id); - break; - } + gtp_set_pktinfo_ipv4(pktinfo, pctx->sk, iph, pctx, rt, &fl4, dev); + gtp_push_header(skb, pktinfo); return 0; err_rt: @@ -731,6 +557,7 @@ static int gtp_build_skb_ip4(struct sk_buff *skb, struct net_device *dev, static netdev_tx_t gtp_dev_xmit(struct sk_buff *skb, struct net_device *dev) { + unsigned int proto = ntohs(skb->protocol); struct gtp_pktinfo pktinfo; int err; @@ -742,22 +569,32 @@ static netdev_tx_t gtp_dev_xmit(struct sk_buff *skb, struct net_device *dev) /* PDP context lookups in gtp_build_skb_*() need rcu read-side lock. */ rcu_read_lock(); - err = gtp_build_skb_ip4(skb, dev, &pktinfo); + switch (proto) { + case ETH_P_IP: + err = gtp_build_skb_ip4(skb, dev, &pktinfo); + break; + default: + err = -EOPNOTSUPP; + break; + } rcu_read_unlock(); if (err < 0) goto tx_err; - udp_tunnel_xmit_skb(pktinfo.rt, pktinfo.sk, skb, - pktinfo.fl4.saddr, - pktinfo.fl4.daddr, - pktinfo.tos, - ip4_dst_hoplimit(&pktinfo.rt->dst), - 0, - pktinfo.gtph_port, - pktinfo.gtph_port, - true, - false); + switch (proto) { + case ETH_P_IP: + netdev_dbg(pktinfo.dev, "gtp -> IP src: %pI4 dst: %pI4\n", + &pktinfo.iph->saddr, &pktinfo.iph->daddr); + udp_tunnel_xmit_skb(pktinfo.rt, pktinfo.sk, skb, + pktinfo.fl4.saddr, pktinfo.fl4.daddr, + pktinfo.iph->tos, + ip4_dst_hoplimit(&pktinfo.rt->dst), + 0, + pktinfo.gtph_port, pktinfo.gtph_port, + true, false); + break; + } return NETDEV_TX_OK; tx_err: @@ -773,19 +610,6 @@ static const struct net_device_ops gtp_netdev_ops = { .ndo_get_stats64 = dev_get_tstats64, }; -static struct gtp_dev *gtp_find_flow_based_dev(struct net *net) -{ - struct gtp_net *gn = net_generic(net, gtp_net_id); - struct gtp_dev *gtp; - - list_for_each_entry(gtp, &gn->gtp_dev_list, list) { - if (gtp->collect_md) - return gtp; - } - - return NULL; -} - static void gtp_link_setup(struct net_device *dev) { dev->netdev_ops = >p_netdev_ops; @@ -810,7 +634,7 @@ static void gtp_link_setup(struct net_device *dev) } static int gtp_hashtable_new(struct gtp_dev *gtp, int hsize); -static int gtp_encap_enable(struct gtp_dev *gtp, struct net_device *dev, struct nlattr *data[]); +static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[]); static void gtp_destructor(struct net_device *dev) { @@ -828,24 +652,11 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev, struct gtp_net *gn; int hashsize, err; - if (!data[IFLA_GTP_FD0] && !data[IFLA_GTP_FD1] && - !data[IFLA_GTP_COLLECT_METADATA]) + if (!data[IFLA_GTP_FD0] && !data[IFLA_GTP_FD1]) return -EINVAL; gtp = netdev_priv(dev); - if (data[IFLA_GTP_COLLECT_METADATA]) { - if (data[IFLA_GTP_FD0]) { - netdev_dbg(dev, "LWT device does not support setting v0 socket"); - return -EINVAL; - } - if (gtp_find_flow_based_dev(src_net)) { - netdev_dbg(dev, "LWT device already exist"); - return -EBUSY; - } - gtp->collect_md = true; - } - if (!data[IFLA_GTP_PDP_HASHSIZE]) { hashsize = 1024; } else { @@ -858,7 +669,7 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev, if (err < 0) return err; - err = gtp_encap_enable(gtp, dev, data); + err = gtp_encap_enable(gtp, data); if (err < 0) goto out_hashtable; @@ -872,7 +683,7 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev, list_add_rcu(>p->list, &gn->gtp_dev_list); dev->priv_destructor = gtp_destructor; - netdev_dbg(dev, "registered new GTP interface %s\n", dev->name); + netdev_dbg(dev, "registered new GTP interface\n"); return 0; @@ -903,7 +714,6 @@ static const struct nla_policy gtp_policy[IFLA_GTP_MAX + 1] = { [IFLA_GTP_FD1] = { .type = NLA_U32 }, [IFLA_GTP_PDP_HASHSIZE] = { .type = NLA_U32 }, [IFLA_GTP_ROLE] = { .type = NLA_U32 }, - [IFLA_GTP_COLLECT_METADATA] = { .type = NLA_FLAG }, }; static int gtp_validate(struct nlattr *tb[], struct nlattr *data[], @@ -927,9 +737,6 @@ static int gtp_fill_info(struct sk_buff *skb, const struct net_device *dev) if (nla_put_u32(skb, IFLA_GTP_PDP_HASHSIZE, gtp->hash_size)) goto nla_put_failure; - if (gtp->collect_md && nla_put_flag(skb, IFLA_GTP_COLLECT_METADATA)) - goto nla_put_failure; - return 0; nla_put_failure: @@ -975,24 +782,35 @@ static int gtp_hashtable_new(struct gtp_dev *gtp, int hsize) return -ENOMEM; } -static int __gtp_encap_enable_socket(struct socket *sock, int type, - struct gtp_dev *gtp) +static struct sock *gtp_encap_enable_socket(int fd, int type, + struct gtp_dev *gtp) { struct udp_tunnel_sock_cfg tuncfg = {NULL}; + struct socket *sock; struct sock *sk; + int err; + + pr_debug("enable gtp on %d, %d\n", fd, type); + + sock = sockfd_lookup(fd, &err); + if (!sock) { + pr_debug("gtp socket fd=%d not found\n", fd); + return NULL; + } sk = sock->sk; if (sk->sk_protocol != IPPROTO_UDP || sk->sk_type != SOCK_DGRAM || (sk->sk_family != AF_INET && sk->sk_family != AF_INET6)) { - pr_debug("socket not UDP\n"); - return -EINVAL; + pr_debug("socket fd=%d not UDP\n", fd); + sk = ERR_PTR(-EINVAL); + goto out_sock; } lock_sock(sk); if (sk->sk_user_data) { - release_sock(sock->sk); - return -EBUSY; + sk = ERR_PTR(-EBUSY); + goto out_rel_sock; } sock_hold(sk); @@ -1003,58 +821,15 @@ static int __gtp_encap_enable_socket(struct socket *sock, int type, tuncfg.encap_destroy = gtp_encap_destroy; setup_udp_tunnel_sock(sock_net(sock->sk), sock, &tuncfg); - release_sock(sock->sk); - return 0; -} -static struct sock *gtp_encap_enable_socket(int fd, int type, - struct gtp_dev *gtp) -{ - struct socket *sock; - int err; - - pr_debug("enable gtp on %d, %d\n", fd, type); - - sock = sockfd_lookup(fd, &err); - if (!sock) { - pr_debug("gtp socket fd=%d not found\n", fd); - return NULL; - } - err = __gtp_encap_enable_socket(sock, type, gtp); +out_rel_sock: + release_sock(sock->sk); +out_sock: sockfd_put(sock); - if (err) - return ERR_PTR(err); - - return sock->sk; + return sk; } -static struct socket *gtp_create_gtp_socket(struct gtp_dev *gtp, struct net_device *dev) -{ - struct udp_port_cfg udp_conf; - struct socket *sock; - int err; - - memset(&udp_conf, 0, sizeof(udp_conf)); - udp_conf.family = AF_INET; - udp_conf.local_ip.s_addr = htonl(INADDR_ANY); - udp_conf.local_udp_port = htons(GTP1U_PORT); - - err = udp_sock_create(dev_net(dev), &udp_conf, &sock); - if (err < 0) { - pr_debug("create gtp sock failed: %d\n", err); - return ERR_PTR(err); - } - err = __gtp_encap_enable_socket(sock, UDP_ENCAP_GTP1U, gtp); - if (err) { - pr_debug("enable gtp sock encap failed: %d\n", err); - udp_tunnel_sock_release(sock); - return ERR_PTR(err); - } - pr_debug("create gtp sock done\n"); - return sock; -} - -static int gtp_encap_enable(struct gtp_dev *gtp, struct net_device *dev, struct nlattr *data[]) +static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[]) { struct sock *sk1u = NULL; struct sock *sk0 = NULL; @@ -1078,25 +853,11 @@ static int gtp_encap_enable(struct gtp_dev *gtp, struct net_device *dev, struct } } - if (data[IFLA_GTP_COLLECT_METADATA]) { - struct socket *sock; - - if (!sk1u) { - sock = gtp_create_gtp_socket(gtp, dev); - if (IS_ERR(sock)) - return PTR_ERR(sock); - - gtp->collect_md_sock = sock; - sk1u = sock->sk; - } else { - gtp->collect_md_sock = NULL; - } - } - if (data[IFLA_GTP_ROLE]) { role = nla_get_u32(data[IFLA_GTP_ROLE]); if (role > GTP_ROLE_SGSN) { - gtp_encap_disable(gtp); + gtp_encap_disable_sock(sk0); + gtp_encap_disable_sock(sk1u); return -EINVAL; } } @@ -1655,7 +1416,7 @@ static int __init gtp_init(void) if (err < 0) goto unreg_genl_family; - pr_info("GTP module loaded (pdp ctx size %zd bytes) with tnl-md support\n", + pr_info("GTP module loaded (pdp ctx size %zd bytes)\n", sizeof(struct pdp_ctx)); return 0; diff --git a/include/uapi/linux/gtp.h b/include/uapi/linux/gtp.h index 62aff78b7c56..79f9191bbb24 100644 --- a/include/uapi/linux/gtp.h +++ b/include/uapi/linux/gtp.h @@ -2,8 +2,6 @@ #ifndef _UAPI_LINUX_GTP_H_ #define _UAPI_LINUX_GTP_H_ -#include - #define GTP_GENL_MCGRP_NAME "gtp" enum gtp_genl_cmds { @@ -36,14 +34,4 @@ enum gtp_attrs { }; #define GTPA_MAX (__GTPA_MAX + 1) -enum { - GTP_METADATA_V1 -}; - -struct gtpu_metadata { - __u8 ver; - __u8 flags; - __u8 type; -}; - #endif /* _UAPI_LINUX_GTP_H_ */ diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index eb8018c3a737..91c8dda6d95d 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -811,7 +811,6 @@ enum { IFLA_GTP_FD1, IFLA_GTP_PDP_HASHSIZE, IFLA_GTP_ROLE, - IFLA_GTP_COLLECT_METADATA, __IFLA_GTP_MAX, }; #define IFLA_GTP_MAX (__IFLA_GTP_MAX - 1) diff --git a/include/uapi/linux/if_tunnel.h b/include/uapi/linux/if_tunnel.h index 802da679fab1..7d9105533c7b 100644 --- a/include/uapi/linux/if_tunnel.h +++ b/include/uapi/linux/if_tunnel.h @@ -176,7 +176,6 @@ enum { #define TUNNEL_VXLAN_OPT __cpu_to_be16(0x1000) #define TUNNEL_NOCACHE __cpu_to_be16(0x2000) #define TUNNEL_ERSPAN_OPT __cpu_to_be16(0x4000) -#define TUNNEL_GTPU_OPT __cpu_to_be16(0x8000) #define TUNNEL_OPTIONS_PRESENT \ (TUNNEL_GENEVE_OPT | TUNNEL_VXLAN_OPT | TUNNEL_ERSPAN_OPT) diff --git a/tools/include/uapi/linux/if_link.h b/tools/include/uapi/linux/if_link.h index 28d649bda686..d208b2af697f 100644 --- a/tools/include/uapi/linux/if_link.h +++ b/tools/include/uapi/linux/if_link.h @@ -617,7 +617,6 @@ enum { IFLA_GTP_FD1, IFLA_GTP_PDP_HASHSIZE, IFLA_GTP_ROLE, - IFLA_GTP_COLLECT_METADATA, __IFLA_GTP_MAX, }; #define IFLA_GTP_MAX (__IFLA_GTP_MAX - 1) From patchwork Wed Feb 3 07:08:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Bonn X-Patchwork-Id: 12063563 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4669C433E0 for ; Wed, 3 Feb 2021 07:09:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 69B4764F58 for ; Wed, 3 Feb 2021 07:09:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232139AbhBCHJC (ORCPT ); Wed, 3 Feb 2021 02:09:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231821AbhBCHIv (ORCPT ); Wed, 3 Feb 2021 02:08:51 -0500 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F0E8C0613D6 for ; Tue, 2 Feb 2021 23:08:11 -0800 (PST) Received: by mail-lf1-x129.google.com with SMTP id i187so31792600lfd.4 for ; Tue, 02 Feb 2021 23:08:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=norrbonn-se.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Axi2g6I6F47I8bzDu1p5LN7RII40A/s6odd4OB1z8JY=; b=PRJkzgszSPpSal7lG0hQCVC6EvhDr0dotAYPYUduntwNeUL/6ksIHgRuNxlxdpopzq jhMXKo6KeylJAusUNFihrRxAiSlP5QMKKbg5oeCpO5w2epwmLizsOBdHhtYGYvb+sHER OZLXFvZdZ5kioqHsxky6VE7lwyZifOfZpEaAEAOxYJytSa1+1SiGcBETXfLAXklRKatW Fe4kWtmip6MSroIZXYYCyqBJmCEsiKr0m5wvmhwo0QB/sGOjS92WoSkJOQPoh8SdFBS8 wsW1bVHj15wjvSr4GAuVBeXl0W+mSmLTQxkru/MTHl1w+eyyP3qxlS5AMSl9g6hRCea1 j1DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Axi2g6I6F47I8bzDu1p5LN7RII40A/s6odd4OB1z8JY=; b=g+vFNEATjZoqmHuzTQRWFC6noas0U5kq1gvIDvfP6pRnnpAodYby9LZU02/yjIx5sV OvMRU1c3YHgMBXLuBkKBYQvHsJrh2DvddJPtWRGhC7Ei0I/4C/W0lfhKTlave+f5duV5 ruXO8K1NFfWaZEpWFpvNovCMlLFR/ejKEHFVqlBa+TP1a9Ju59I1N32HCAdL8v0r/Ck+ cxT2yn549P/2uICyRF4oIJGHuX/oazR/wFTBIQApmIaQ8XqNsRIlGP/SpukvfP1JyHFO nfMkxR0z4QL2dpEFQaKSkX0zZOmSPHINyaBgkdUFqc3xehTL8w0nKVCK5qJTx3ahWT9S +geg== X-Gm-Message-State: AOAM532c+rPivr5pqJCQOUYEjKAJ8bMPeZRMLbfsUOpP444QXrNiE0az 49cR8+epew8KUh/ws0CgZF3pog== X-Google-Smtp-Source: ABdhPJyePV3Wi4Ej9ZkKm6ASV9ekVh7KdknMQ+ziOG0eTO4u/2LtsWpz7MQR8Lcx40+7PtFz5/xDvg== X-Received: by 2002:a19:4f4f:: with SMTP id a15mr1003458lfk.309.1612336089831; Tue, 02 Feb 2021 23:08:09 -0800 (PST) Received: from mimer.emblasoft.lan (h-137-65.A159.priv.bahnhof.se. [81.170.137.65]) by smtp.gmail.com with ESMTPSA id d3sm147367lfg.122.2021.02.02.23.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 23:08:09 -0800 (PST) From: Jonas Bonn To: laforge@gnumonks.org, kuba@kernel.org, netdev@vger.kernel.org, pablo@netfilter.org Cc: Jonas Bonn Subject: [PATCH net-next v2 2/7] gtp: set initial MTU Date: Wed, 3 Feb 2021 08:08:00 +0100 Message-Id: <20210203070805.281321-3-jonas@norrbonn.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210203070805.281321-1-jonas@norrbonn.se> References: <20210202065159.227049-1-jonas@norrbonn.se> <20210203070805.281321-1-jonas@norrbonn.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The GTP link is brought up with a default MTU of zero. This can lead to some rather unexpected behaviour for users who are more accustomed to interfaces coming online with reasonable defaults. This patch sets an initial MTU for the GTP link of 1500 less worst-case tunnel overhead. Signed-off-by: Jonas Bonn Acked-by: Harald Welte --- drivers/net/gtp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index 4c04e271f184..5a048f050a9c 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -612,11 +612,16 @@ static const struct net_device_ops gtp_netdev_ops = { static void gtp_link_setup(struct net_device *dev) { + unsigned int max_gtp_header_len = sizeof(struct iphdr) + + sizeof(struct udphdr) + + sizeof(struct gtp0_header); + dev->netdev_ops = >p_netdev_ops; dev->needs_free_netdev = true; dev->hard_header_len = 0; dev->addr_len = 0; + dev->mtu = ETH_DATA_LEN - max_gtp_header_len; /* Zero header length. */ dev->type = ARPHRD_NONE; @@ -626,11 +631,7 @@ static void gtp_link_setup(struct net_device *dev) dev->features |= NETIF_F_LLTX; netif_keep_dst(dev); - /* Assume largest header, ie. GTPv0. */ - dev->needed_headroom = LL_MAX_HEADER + - sizeof(struct iphdr) + - sizeof(struct udphdr) + - sizeof(struct gtp0_header); + dev->needed_headroom = LL_MAX_HEADER + max_gtp_header_len; } static int gtp_hashtable_new(struct gtp_dev *gtp, int hsize); From patchwork Wed Feb 3 07:08:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Bonn X-Patchwork-Id: 12063567 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1AD6C433E0 for ; Wed, 3 Feb 2021 07:09:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77CE964F58 for ; Wed, 3 Feb 2021 07:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232185AbhBCHJK (ORCPT ); Wed, 3 Feb 2021 02:09:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232063AbhBCHIw (ORCPT ); Wed, 3 Feb 2021 02:08:52 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EED5C0613ED for ; Tue, 2 Feb 2021 23:08:12 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id b2so31844069lfq.0 for ; Tue, 02 Feb 2021 23:08:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=norrbonn-se.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BGpaEg0j3hIwyT8YaseDu5lYmdNhnyii6Jj6H/mUeXo=; b=SrBB7QvA95msna1CXnwB4FT1PiIyEtTe98i0XdNsRlzCAMVweHitTGoXL1HFNtAUkz 04WXtj+nXB3sHHb2zPyyPydYMqHUKDYc1C96LmDopH5KV8y6YjLkSuMK6Fg+qTjH9uUc IZvDBkT4fRA30z384suXuawaRCBXgOogqa78AcIOdqji+OBotQTdCgDmqozs+s2iuyK0 LFERMYBcYeXNFKvry9dzM8fyqu/XPmfb1Cc8Kf2cgli6qcFgBl2QgQUVyum+RDktes3Y 2SJuQ+okkMQXUqY+weVYtcZnFtcOA5RXGfyXJoANLGBd+ynW3VwP5nU9DlildJrOoXan BWnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BGpaEg0j3hIwyT8YaseDu5lYmdNhnyii6Jj6H/mUeXo=; b=B6LyiEGEsL9ptbrwcnk+Aa2PqrMlvyp68m6eHv5OaWRMRw+akff5s69CMPVGMvlt1f nbMTH+boqU2djh1xkceAeKOFLzGRfkmrxUjPnBaqvakcuYXO7UBYzmzdR91Ja4/MpLc4 hEMGoZCXHfCiDgHPlr/AqqGsrnB/M51rsf2MEuTeJ5A8e7aQLCr0eDxkNUbKMHB6DGOx 2Zaate42RhYFZ69yFN6UcxwgA3qo6RVmE0CKx9WR66jQ6CWiXxL7EJMh/hsxE5pHO9Xd cPZqpf90fB4m2ew+gSJysagU1aPb+G3HaVnwL/o/gk7m/85+Qu0ACQsrc0W/5SX+7XhJ uUWA== X-Gm-Message-State: AOAM533xQ+UWcTpqMyX9wvuOvaBqHAaewmbg1V8GkTouG2m43jhR9d7s jSAnnUVttPPtJBQzmhpvbxfsKry0Ok0G5Q== X-Google-Smtp-Source: ABdhPJzCVq6jCBkcI53pH+twexFVq4JgLEZyCH4e/NPfELAJ+gQhoWcwkgqocI96oukLF275bVDmoA== X-Received: by 2002:a05:6512:52f:: with SMTP id o15mr949378lfc.401.1612336090618; Tue, 02 Feb 2021 23:08:10 -0800 (PST) Received: from mimer.emblasoft.lan (h-137-65.A159.priv.bahnhof.se. [81.170.137.65]) by smtp.gmail.com with ESMTPSA id d3sm147367lfg.122.2021.02.02.23.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 23:08:10 -0800 (PST) From: Jonas Bonn To: laforge@gnumonks.org, kuba@kernel.org, netdev@vger.kernel.org, pablo@netfilter.org Cc: Jonas Bonn Subject: [PATCH net-next v2 3/7] gtp: include role in link info Date: Wed, 3 Feb 2021 08:08:01 +0100 Message-Id: <20210203070805.281321-4-jonas@norrbonn.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210203070805.281321-1-jonas@norrbonn.se> References: <20210202065159.227049-1-jonas@norrbonn.se> <20210203070805.281321-1-jonas@norrbonn.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Querying link info for the GTP interface doesn't reveal in which "role" the device is set to operate. Include this information in the info query result. Signed-off-by: Jonas Bonn Acked-by: Harald Welte --- drivers/net/gtp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index 5a048f050a9c..5682d3ba7aa5 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -728,7 +728,8 @@ static int gtp_validate(struct nlattr *tb[], struct nlattr *data[], static size_t gtp_get_size(const struct net_device *dev) { - return nla_total_size(sizeof(__u32)); /* IFLA_GTP_PDP_HASHSIZE */ + return nla_total_size(sizeof(__u32)) + /* IFLA_GTP_PDP_HASHSIZE */ + nla_total_size(sizeof(__u32)); /* IFLA_GTP_ROLE */ } static int gtp_fill_info(struct sk_buff *skb, const struct net_device *dev) @@ -737,6 +738,8 @@ static int gtp_fill_info(struct sk_buff *skb, const struct net_device *dev) if (nla_put_u32(skb, IFLA_GTP_PDP_HASHSIZE, gtp->hash_size)) goto nla_put_failure; + if (nla_put_u32(skb, IFLA_GTP_ROLE, gtp->role)) + goto nla_put_failure; return 0; From patchwork Wed Feb 3 07:08:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Bonn X-Patchwork-Id: 12063569 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 066E4C433E0 for ; Wed, 3 Feb 2021 07:09:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B4F0364F5D for ; Wed, 3 Feb 2021 07:09:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232151AbhBCHJ0 (ORCPT ); Wed, 3 Feb 2021 02:09:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232091AbhBCHIx (ORCPT ); Wed, 3 Feb 2021 02:08:53 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D607BC061786 for ; Tue, 2 Feb 2021 23:08:12 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id e15so11633383lft.13 for ; Tue, 02 Feb 2021 23:08:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=norrbonn-se.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2qm3Xf/zORcOQpWtLlmivgXe4uJE/D2V+lZIMUhUMIQ=; b=HZq6xd0jrau2UUGd8RazP2caKKcGOEUws5DW2iUGYC7CbtpHAIQ0EZdazimixZb4Q7 roE1csgP0IxWmHK1dLAqHzvFB0y11IYSDaoWK//DZgoTjcz6xPoYi/6rpVp3u/Fo7zC7 UXeRDm7AMQ2d9cWMEQC8duCWWaAr3qhjyjD097JyWXHd6PhmPDHdpRDx9etIL7vGkQoJ 8HhuZDx6xuHDC4RnsKnRWELsWyZS+6QetLgebKyEwxI4qiZiaybWxQQsiyCEWN9I8KPW zjXui9NHcrALSkAu62ZQEO2QPzEC480jYpaqxtx+nGRWH5NtVDOjvfvcDlyE75rbFhjQ FfDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2qm3Xf/zORcOQpWtLlmivgXe4uJE/D2V+lZIMUhUMIQ=; b=thVJBxEYR2rXOIVudR8Xb9PrQj2HKWqwFOvFCV1GfJSgI6BxhleLTk2qTvQyi6PbMY aAu29gY+zCcd1ekGhH2WbgiZno+/nX9LB/NCHzWayyrl5dFmxc4+8Hxfl7jFodo+1zXB n7ZeZ/R+XEYQMif0L8edO2eUKUQve4KbSC1jj9Zjh+vWvEob8v1FUjYJF+4/7IHu3md2 I5A98lw+DPK70Yl+Bkq3X/hM92kFVpEU2uHvoKc5YJMMB9VBbH25VfsQDOt64KiUPj/1 Lh3HDnmaWy/E8ej3F9mb8Dd/9MCEmo6AlYe+oLw+I/PTy/F7OlYy+mYqyG28eM7TAY1G ueNw== X-Gm-Message-State: AOAM530s5F8pHaeeDf7S99GUphFfzdbYWgkWjdvhkREwVsNY15HBlH59 6zrr9vYBZ/u73s1FcHR9U7pcKg== X-Google-Smtp-Source: ABdhPJw6F5kU3B/MzIKWyYBLE/GYEcSy3gLixgfBje5xBPQPkddClKblYR96BKPElFoCfPT7ca3g/g== X-Received: by 2002:a19:5f0a:: with SMTP id t10mr976931lfb.568.1612336091447; Tue, 02 Feb 2021 23:08:11 -0800 (PST) Received: from mimer.emblasoft.lan (h-137-65.A159.priv.bahnhof.se. [81.170.137.65]) by smtp.gmail.com with ESMTPSA id d3sm147367lfg.122.2021.02.02.23.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 23:08:10 -0800 (PST) From: Jonas Bonn To: laforge@gnumonks.org, kuba@kernel.org, netdev@vger.kernel.org, pablo@netfilter.org Cc: Jonas Bonn Subject: [PATCH net-next v2 4/7] gtp: really check namespaces before xmit Date: Wed, 3 Feb 2021 08:08:02 +0100 Message-Id: <20210203070805.281321-5-jonas@norrbonn.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210203070805.281321-1-jonas@norrbonn.se> References: <20210202065159.227049-1-jonas@norrbonn.se> <20210203070805.281321-1-jonas@norrbonn.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Blindly assuming that packet transmission crosses namespaces results in skb marks being lost in the single namespace case. Signed-off-by: Jonas Bonn Acked-by: Harald Welte --- drivers/net/gtp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index 5682d3ba7aa5..e4e57c0552ee 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -592,7 +592,9 @@ static netdev_tx_t gtp_dev_xmit(struct sk_buff *skb, struct net_device *dev) ip4_dst_hoplimit(&pktinfo.rt->dst), 0, pktinfo.gtph_port, pktinfo.gtph_port, - true, false); + !net_eq(sock_net(pktinfo.pctx->sk), + dev_net(dev)), + false); break; } From patchwork Wed Feb 3 07:08:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Bonn X-Patchwork-Id: 12063571 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D61DC433DB for ; Wed, 3 Feb 2021 07:09:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38B7064F61 for ; Wed, 3 Feb 2021 07:09:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231781AbhBCHJh (ORCPT ); Wed, 3 Feb 2021 02:09:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231865AbhBCHJb (ORCPT ); Wed, 3 Feb 2021 02:09:31 -0500 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A50EAC061788 for ; Tue, 2 Feb 2021 23:08:13 -0800 (PST) Received: by mail-lj1-x233.google.com with SMTP id e18so27058445lja.12 for ; Tue, 02 Feb 2021 23:08:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=norrbonn-se.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9mXvPzB0HDHgpYjkrEj9f1/KsmShypuTCsJLlqyoYZI=; b=f0q4HTD32DxLDfjsOglhbNvLI4WGG6thLqtX0+y4VlR0Wt/15nArsToQHXfzc7tXtl mqdszZzdJxnH4qNBVVApiUqbEwf3W8qZJs/Q5HUWnLrpW0qBBTzpBlxpaymdWOgx6Mt5 bzSIx3KHfm39Ug/dKMnvh0J673wDyrVgH3BMjSZuoGe2VHaRlVKIu4BcYG5FjOn5NItX Mp6fdG3iXAF4H+IFmioOzK+uIZaf9h9xnGjzjVpYFE6etwQXHfi0sa3Le2Wb8e9zXwsq zLUbcXqS2SqBKx5ziuoQHBP604yF8CLMetYXYXNIkZcz9sOxKMqLMY1Cf0yKlTCMIuSR fmUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9mXvPzB0HDHgpYjkrEj9f1/KsmShypuTCsJLlqyoYZI=; b=tVZ/gJXGSSYAGDpqicF3axd+gdKcrSoBV63n1mnBZoDL9MeuGIKFNNKJ2ppA4W3TGr HFdVUCDJGqz1KKP00/QPmBwXyKkB3fE+B1XrGP1VvsC20OIjN5IYqvCb3Cl0naON7Pz0 Ww0y9cd7SSe1liO/dElCJfP+LrmA0PEnS5tisxYd0obYccghBiSXA8rEJLx5O/kyQyCt JTQJ9HCmGROBjqU9p4ymHBsRqPDOUq/ewQpLBxSM3SRV0wzi9AXr5hN51q7HyNbZ3MEG FRkPS6NbZFOJWqhLc0bM7jKxA5KzxWGhwsPpYtHUmsv4e7fACPLhj78mjhynJNNgHEHK JJHQ== X-Gm-Message-State: AOAM531wN82kqsY6Q+jNKhICJ5hItj6gvLfRgPOl3wru4CdLbM+bUCeO GGMS15ThdnsTVoJ8fmL3pYH/Lg== X-Google-Smtp-Source: ABdhPJylWabs8kp55zQyEW6Vw1uM1sb4EhLt7cja7pNJeYe+/bNuOWtO86xq0ZuniadgoGxazTJlcw== X-Received: by 2002:a05:651c:482:: with SMTP id s2mr961554ljc.193.1612336092203; Tue, 02 Feb 2021 23:08:12 -0800 (PST) Received: from mimer.emblasoft.lan (h-137-65.A159.priv.bahnhof.se. [81.170.137.65]) by smtp.gmail.com with ESMTPSA id d3sm147367lfg.122.2021.02.02.23.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 23:08:11 -0800 (PST) From: Jonas Bonn To: laforge@gnumonks.org, kuba@kernel.org, netdev@vger.kernel.org, pablo@netfilter.org Cc: Jonas Bonn Subject: [PATCH net-next v2 5/7] gtp: drop unnecessary call to skb_dst_drop Date: Wed, 3 Feb 2021 08:08:03 +0100 Message-Id: <20210203070805.281321-6-jonas@norrbonn.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210203070805.281321-1-jonas@norrbonn.se> References: <20210202065159.227049-1-jonas@norrbonn.se> <20210203070805.281321-1-jonas@norrbonn.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The call to skb_dst_drop() is already done as part of udp_tunnel_xmit(). Signed-off-by: Jonas Bonn Acked-by: Harald Welte --- drivers/net/gtp.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index e4e57c0552ee..04d9de385549 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -515,8 +515,6 @@ static int gtp_build_skb_ip4(struct sk_buff *skb, struct net_device *dev, goto err_rt; } - skb_dst_drop(skb); - /* This is similar to tnl_update_pmtu(). */ df = iph->frag_off; if (df) { From patchwork Wed Feb 3 07:08:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Bonn X-Patchwork-Id: 12063573 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4A8AC433DB for ; Wed, 3 Feb 2021 07:09:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A58DF64F5D for ; Wed, 3 Feb 2021 07:09:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232123AbhBCHJo (ORCPT ); Wed, 3 Feb 2021 02:09:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232026AbhBCHJb (ORCPT ); Wed, 3 Feb 2021 02:09:31 -0500 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8595DC06178A for ; Tue, 2 Feb 2021 23:08:14 -0800 (PST) Received: by mail-lj1-x22e.google.com with SMTP id a25so27097446ljn.0 for ; Tue, 02 Feb 2021 23:08:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=norrbonn-se.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uEnUir7NULfyhfcHWwSmbaRoX9scIfA0jMqc4I/U48c=; b=ZGZcdabvWHlf+jUXykVA5NeDRmuGmE9m43aL21YQg0bjDhJ4HYcaYfSiJ/B6oTOuZV fUcuBwdzAL2yo1899Tu+M+549ZIHW+9NERMmO6HkmjdJCQhA/b+skR5f3F5ODD+5PcpN cSwB1ZH0piufRTunWFsHscogA9beB0O62R7YHoeg1RRjivwz8l+3vT6RasYYDeIUSIrz kKmdHwGc0OdTMD8ULgB6ElIgOlMTL7mLVAZ3PJ9Hj34qSKd0jC63M9P7Dm9SgK0ID5dZ +rbotxaoNamFU7nErbpGshgq8xXrehooO0tpeq8TEeNWfmZFFWZNTMgtW/OnObWCGrhF gTgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uEnUir7NULfyhfcHWwSmbaRoX9scIfA0jMqc4I/U48c=; b=rrvmAi0ZQAMPDkRAN1AjFqa/WG/Bc6V0u/QgPrZ8/cULmF8kA/biG5JXa/qITACYXG DVN5EhHclCMAcMHI7q/Obe64gxQ6cY7KMSBSIvAb/ek19MUeK8ZvGo5PpQ1fbRoF090n 2IqYdVtpmCzQ6ImvBz+EPJ0pa7f/iaDGnqJw2JYbgzFcGMKurKGm3iqDy+N52mqxyWNA fubTBZBgdkJRuMx1j12+vvTCNSMThz+G8oyxPkEF8oaKF9/dHLQxRkCLg5EkRipGzAMN CHjj8XtNx98MWS7RZ6CYz6eKKnVHeX9LjdoIfcsO+WZ/rCPO2TKI1doaFUVfjf5k0gqr JYjA== X-Gm-Message-State: AOAM533bH9a3eBoDETG7V0ENuN6rH1RKAxGL0HvQpaUHDa12xlhYTa8y 4EgFLythDEy5Jy++lH+OkZA0Fg== X-Google-Smtp-Source: ABdhPJxEQNW/OeCtMmYK85ZJ/2Pjotrwz3oLhbzm5jabpVSK5yeCQzkI2fxVsPdz1/F+CigFDAhFWQ== X-Received: by 2002:a2e:6c02:: with SMTP id h2mr953711ljc.277.1612336092970; Tue, 02 Feb 2021 23:08:12 -0800 (PST) Received: from mimer.emblasoft.lan (h-137-65.A159.priv.bahnhof.se. [81.170.137.65]) by smtp.gmail.com with ESMTPSA id d3sm147367lfg.122.2021.02.02.23.08.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 23:08:12 -0800 (PST) From: Jonas Bonn To: laforge@gnumonks.org, kuba@kernel.org, netdev@vger.kernel.org, pablo@netfilter.org Cc: Jonas Bonn Subject: [PATCH net-next v2 6/7] gtp: set device type Date: Wed, 3 Feb 2021 08:08:04 +0100 Message-Id: <20210203070805.281321-7-jonas@norrbonn.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210203070805.281321-1-jonas@norrbonn.se> References: <20210202065159.227049-1-jonas@norrbonn.se> <20210203070805.281321-1-jonas@norrbonn.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Set the devtype to 'gtp' when setting up the link. Signed-off-by: Jonas Bonn Acked-by: Harald Welte --- drivers/net/gtp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index 04d9de385549..a1bb02818977 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -610,6 +610,10 @@ static const struct net_device_ops gtp_netdev_ops = { .ndo_get_stats64 = dev_get_tstats64, }; +static const struct device_type gtp_type = { + .name = "gtp", +}; + static void gtp_link_setup(struct net_device *dev) { unsigned int max_gtp_header_len = sizeof(struct iphdr) + @@ -618,6 +622,7 @@ static void gtp_link_setup(struct net_device *dev) dev->netdev_ops = >p_netdev_ops; dev->needs_free_netdev = true; + SET_NETDEV_DEVTYPE(dev, >p_type); dev->hard_header_len = 0; dev->addr_len = 0; From patchwork Wed Feb 3 07:08:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Bonn X-Patchwork-Id: 12063575 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF5FCC433DB for ; Wed, 3 Feb 2021 07:09:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8395064F5D for ; Wed, 3 Feb 2021 07:09:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232236AbhBCHJs (ORCPT ); Wed, 3 Feb 2021 02:09:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232091AbhBCHJf (ORCPT ); Wed, 3 Feb 2021 02:09:35 -0500 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41D7EC06178B for ; Tue, 2 Feb 2021 23:08:15 -0800 (PST) Received: by mail-lj1-x236.google.com with SMTP id e18so27058505lja.12 for ; Tue, 02 Feb 2021 23:08:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=norrbonn-se.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pZGVcxEVCheiG0wA/Yq7OXQtrC7VpDVqrb8lgaXPAlI=; b=CJNkmrlxCA31zUIsKLsM306hmb13GPfZlnxgG+g/SAyjuw6A6KxnNXFhmKYNSkkFtP FRput2SQdyeubp5rFRcoICgCST7RfknowFFmjfTO0q4pAgO3qIPr/X6fpaF5xuwPeGKD uLGHtz0Ahle/Iy6n8xLGNm+mxdx66EsxeNO0OfYVI8nJUCZtvbpgNX3PsinDG2FQXm8n 6ushkqWIhp3kRzv3uBcvbnlNg2dXnKTbmDiDxTtRpeUlk9GcEZjA6zD+Q9nwBQ/5rIDK QcDQGiHeBRloeJ34EGeywYUQzKrBDAPVUqnNkHWKstHkYka2qmb7fPDgvpJKpv8E/I8U RApQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pZGVcxEVCheiG0wA/Yq7OXQtrC7VpDVqrb8lgaXPAlI=; b=t0XY72ztIDxitLI9sWl2VKzdVx3WbwSRzRPwLnq2n1i6XfaR3Ntp+8XINK/ioP1QxD SzdH3u7kdD4+BfIopx7SMKy/6NgOcv19hcaobW2J9de0vQU2JGWEueiDHZ2Yz1UHVoXN f3yTnx2ns1V0Xcooz+ECMiyJXhU7/5p0h20rs8s1gnxcZGhbNcBBAekADBdsX6Q8T1sl BYA0Nk/4XqijbBvpv69KTq/lR/rDMrnpmvRHql50M4C87mDRfjMjCfmbMxEircTeYuK4 A+k0aO2CBtPOWnuatztzCXFmSH9I1OrkLbVrLIn6EM5OBisM7x9a7yUDE4FZT5RcB7X1 Jdbw== X-Gm-Message-State: AOAM532ps5g2XzsC2cb9aMu/6ICDcDXswnLUc/ktvkbZzRuFhq8U3leP aN09BAhHgJ3W87IlmxFzP1yLw1zDpDW5nA== X-Google-Smtp-Source: ABdhPJzu0HWiD0XoBkisDW4TuItdQssRfnHATxF8DhqstVLDpZik13MZ+7Kw0gjDbkHONSBZ3aOhcg== X-Received: by 2002:a2e:3a18:: with SMTP id h24mr958225lja.170.1612336093800; Tue, 02 Feb 2021 23:08:13 -0800 (PST) Received: from mimer.emblasoft.lan (h-137-65.A159.priv.bahnhof.se. [81.170.137.65]) by smtp.gmail.com with ESMTPSA id d3sm147367lfg.122.2021.02.02.23.08.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Feb 2021 23:08:13 -0800 (PST) From: Jonas Bonn To: laforge@gnumonks.org, kuba@kernel.org, netdev@vger.kernel.org, pablo@netfilter.org Cc: Jonas Bonn Subject: [PATCH net-next v2 7/7] gtp: update rx_length_errors for abnormally short packets Date: Wed, 3 Feb 2021 08:08:05 +0100 Message-Id: <20210203070805.281321-8-jonas@norrbonn.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210203070805.281321-1-jonas@norrbonn.se> References: <20210202065159.227049-1-jonas@norrbonn.se> <20210203070805.281321-1-jonas@norrbonn.se> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Based on work by Pravin Shelar. Update appropriate stats when packet transmission isn't possible. Signed-off-by: Jonas Bonn Acked-by: Harald Welte --- drivers/net/gtp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index a1bb02818977..9a70f05baf6e 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -189,8 +189,10 @@ static int gtp_rx(struct pdp_ctx *pctx, struct sk_buff *skb, /* Get rid of the GTP + UDP headers. */ if (iptunnel_pull_header(skb, hdrlen, skb->protocol, - !net_eq(sock_net(pctx->sk), dev_net(pctx->dev)))) - return -1; + !net_eq(sock_net(pctx->sk), dev_net(pctx->dev)))) { + pctx->dev->stats.rx_length_errors++; + goto err; + } netdev_dbg(pctx->dev, "forwarding packet from GGSN to uplink\n"); @@ -206,6 +208,10 @@ static int gtp_rx(struct pdp_ctx *pctx, struct sk_buff *skb, netif_rx(skb); return 0; + +err: + pctx->dev->stats.rx_dropped++; + return -1; } /* 1 means pass up to the stack, -1 means drop and 0 means decapsulated. */