Re: [PATCH net-next v8 12/24] ovpn: store tunnel and transport statistics

2024-10-03 Thread kernel test robot
Hi Antonio,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 44badc908f2c85711cb18e45e13119c10ad3a05f]

url:
https://github.com/intel-lab-lkp/linux/commits/Antonio-Quartulli/netlink-add-NLA_POLICY_MAX_LEN-macro/20241002-172734
base:   44badc908f2c85711cb18e45e13119c10ad3a05f
patch link:
https://lore.kernel.org/r/20241002-b4-ovpn-v8-12-37ceffcffbde%40openvpn.net
patch subject: [PATCH net-next v8 12/24] ovpn: store tunnel and transport 
statistics
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 
3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202410031618.cvko8ujs-...@intel.com/

includecheck warnings: (new ones prefixed by >>)
>> drivers/net/ovpn/peer.h: uapi/linux/ovpn.h is included more than once.
>> drivers/net/ovpn/peer.h: net/dst_cache.h is included more than once.

vim +14 drivers/net/ovpn/peer.h

12  
13  #include 
  > 14  #include 
15  
16  #include "bind.h"
17  #include "pktid.h"
18  #include "crypto.h"
19  #include "socket.h"
20  #include "stats.h"
21  
22  #include 
  > 23  #include 
24  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki



[PATCH net-next v8 12/24] ovpn: store tunnel and transport statistics

2024-10-02 Thread Antonio Quartulli
Byte/packet counters for in-tunnel and transport streams
are now initialized and updated as needed.

To be exported via netlink.

Signed-off-by: Antonio Quartulli 
---
 drivers/net/ovpn/Makefile  |  1 +
 drivers/net/ovpn/crypto_aead.c |  2 ++
 drivers/net/ovpn/io.c  | 12 +++
 drivers/net/ovpn/peer.c|  3 +++
 drivers/net/ovpn/peer.h|  8 +++
 drivers/net/ovpn/skb.h |  1 +
 drivers/net/ovpn/stats.c   | 21 +++
 drivers/net/ovpn/stats.h   | 47 ++
 8 files changed, 95 insertions(+)

diff --git a/drivers/net/ovpn/Makefile b/drivers/net/ovpn/Makefile
index 
ccdaeced1982c851475657860a005ff2b9dfbd13..d43fda72646bdc7644d9a878b56da0a0e5680c98
 100644
--- a/drivers/net/ovpn/Makefile
+++ b/drivers/net/ovpn/Makefile
@@ -17,4 +17,5 @@ ovpn-y += netlink-gen.o
 ovpn-y += peer.o
 ovpn-y += pktid.o
 ovpn-y += socket.o
+ovpn-y += stats.o
 ovpn-y += udp.o
diff --git a/drivers/net/ovpn/crypto_aead.c b/drivers/net/ovpn/crypto_aead.c
index 
97134ac679c67a3d44a0bf49c2ddf058fd7c0e99..6599c8550390a60d3b0fb9c144beb8c7871bc320
 100644
--- a/drivers/net/ovpn/crypto_aead.c
+++ b/drivers/net/ovpn/crypto_aead.c
@@ -128,6 +128,7 @@ int ovpn_aead_encrypt(struct ovpn_peer *peer, struct 
ovpn_crypto_key_slot *ks,
aead_request_set_crypt(req, sg, sg, skb->len - head_size, iv);
aead_request_set_ad(req, OVPN_OP_SIZE_V2 + NONCE_WIRE_SIZE);
 
+   ovpn_skb_cb(skb)->ctx->orig_len = skb->len;
ovpn_skb_cb(skb)->ctx->peer = peer;
ovpn_skb_cb(skb)->ctx->req = req;
ovpn_skb_cb(skb)->ctx->ks = ks;
@@ -216,6 +217,7 @@ int ovpn_aead_decrypt(struct ovpn_peer *peer, struct 
ovpn_crypto_key_slot *ks,
 
aead_request_set_ad(req, NONCE_WIRE_SIZE + OVPN_OP_SIZE_V2);
 
+   ovpn_skb_cb(skb)->ctx->orig_len = skb->len;
ovpn_skb_cb(skb)->ctx->payload_offset = payload_offset;
ovpn_skb_cb(skb)->ctx->peer = peer;
ovpn_skb_cb(skb)->ctx->req = req;
diff --git a/drivers/net/ovpn/io.c b/drivers/net/ovpn/io.c
index 
a75aa301b99e6abff04d5cb289b26b5979906ae5..d54af1a0f03a33b03001a041e62554b35a7f5ebc
 100644
--- a/drivers/net/ovpn/io.c
+++ b/drivers/net/ovpn/io.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "ovpnstruct.h"
 #include "peer.h"
@@ -20,6 +21,7 @@
 #include "crypto_aead.h"
 #include "netlink.h"
 #include "proto.h"
+#include "socket.h"
 #include "udp.h"
 #include "skb.h"
 
@@ -66,6 +68,7 @@ void ovpn_decrypt_post(void *data, int ret)
unsigned int payload_offset = 0;
struct ovpn_peer *peer = NULL;
struct sk_buff *skb = data;
+   unsigned int orig_len = 0;
__be16 proto;
__be32 *pid;
 
@@ -80,6 +83,7 @@ void ovpn_decrypt_post(void *data, int ret)
payload_offset = ovpn_skb_cb(skb)->ctx->payload_offset;
ks = ovpn_skb_cb(skb)->ctx->ks;
peer = ovpn_skb_cb(skb)->ctx->peer;
+   orig_len = ovpn_skb_cb(skb)->ctx->orig_len;
 
aead_request_free(ovpn_skb_cb(skb)->ctx->req);
kfree(ovpn_skb_cb(skb)->ctx);
@@ -133,6 +137,10 @@ void ovpn_decrypt_post(void *data, int ret)
goto drop;
}
 
+   /* increment RX stats */
+   ovpn_peer_stats_increment_rx(&peer->vpn_stats, skb->len);
+   ovpn_peer_stats_increment_rx(&peer->link_stats, orig_len);
+
ovpn_netdev_write(peer, skb);
/* skb is passed to upper layer - don't free it */
skb = NULL;
@@ -171,6 +179,7 @@ void ovpn_encrypt_post(void *data, int ret)
 {
struct ovpn_peer *peer = NULL;
struct sk_buff *skb = data;
+   unsigned int orig_len = 0;
 
/* encryption is happening asynchronously. This function will be
 * called later by the crypto callback with a proper return value
@@ -181,6 +190,7 @@ void ovpn_encrypt_post(void *data, int ret)
/* crypto is done, cleanup skb CB and its members */
if (likely(ovpn_skb_cb(skb)->ctx)) {
peer = ovpn_skb_cb(skb)->ctx->peer;
+   orig_len = ovpn_skb_cb(skb)->ctx->orig_len;
 
ovpn_crypto_key_slot_put(ovpn_skb_cb(skb)->ctx->ks);
aead_request_free(ovpn_skb_cb(skb)->ctx->req);
@@ -192,6 +202,8 @@ void ovpn_encrypt_post(void *data, int ret)
goto err;
 
skb_mark_not_on_list(skb);
+   ovpn_peer_stats_increment_tx(&peer->link_stats, skb->len);
+   ovpn_peer_stats_increment_tx(&peer->vpn_stats, orig_len);
 
switch (peer->sock->sock->sk->sk_protocol) {
case IPPROTO_UDP:
diff --git a/drivers/net/ovpn/peer.c b/drivers/net/ovpn/peer.c
index 
212d1210bc564ae804899d7c3bf8c2231e732cf1..6d34c56a4a51ce407b20b6175e6140aafc4b4e33
 100644
--- a/drivers/net/ovpn/peer.c
+++ b/drivers/net/ovpn/peer.c
@@ -18,6 +18,7 @@
 #include "main.h"
 #include "netlink.h"
 #include "peer.h"
+#include "socket.h"
 
 /**
  * ovpn_peer_new - allocate and initialize a new peer object
@@ -47,