diff mbox series

[net-next,7/7] gtp: update rx_length_errors for abnormally short packets

Message ID 20210202065159.227049-8-jonas@norrbonn.se (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series GTP | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 2 maintainers not CCed: davem@davemloft.net osmocom-net-gprs@lists.osmocom.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit fail Errors and warnings before: 0 this patch: 6
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 22 lines checked
netdev/build_allmodconfig_warn fail Errors and warnings before: 0 this patch: 6
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Jonas Bonn Feb. 2, 2021, 6:51 a.m. UTC
Based on work by Pravin Shelar.

Update appropriate stats when packet transmission isn't possible.

Signed-off-by: Jonas Bonn <jonas@norrbonn.se>
Acked-by: Harald Welte <laforge@gnumonks.org>
---
 drivers/net/gtp.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Jakub Kicinski Feb. 2, 2021, 10 p.m. UTC | #1
On Tue,  2 Feb 2021 07:51:59 +0100 Jonas Bonn wrote:
> diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
> index a1bb02818977..fa8880c51101 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)))) {
> +		gtp->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:
> +	gtp->dev->stats.rx_dropped++;
> +	return -1;
>  }
>  
>  /* 1 means pass up to the stack, -1 means drop and 0 means decapsulated. */

drivers/net/gtp.c: In function ‘gtp_rx’:
drivers/net/gtp.c:193:3: error: ‘gtp’ undeclared (first use in this function)
  193 |   gtp->dev->stats.rx_length_errors++;
      |   ^~~
drivers/net/gtp.c:193:3: note: each undeclared identifier is reported only once for each function it appears in


Thanks for working on these patches!
diff mbox series

Patch

diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index a1bb02818977..fa8880c51101 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)))) {
+		gtp->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:
+	gtp->dev->stats.rx_dropped++;
+	return -1;
 }
 
 /* 1 means pass up to the stack, -1 means drop and 0 means decapsulated. */