libpfring: update to 8.6.1
authorRosen Penev <rosenp@gmail.com>
Thu, 16 May 2024 00:52:21 +0000 (17:52 -0700)
committerRosen Penev <rosenp@gmail.com>
Thu, 16 May 2024 02:43:06 +0000 (19:43 -0700)
Remove upstreamed patch, backport one, and switch one from downstream to
upstream patch.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
libs/libpfring/Makefile
libs/libpfring/patches/0001-fix-cross-compiling.patch
libs/libpfring/patches/002-implement-probabilistic-sampling.patch [deleted file]
libs/libpfring/patches/010-gcc14.patch [new file with mode: 0644]
libs/libpfring/patches/100-fix-compilation-warning.patch
libs/libpfring/patches/101-kernel-pf_ring-better-define-sa_data-size.patch
libs/libpfring/patches/102-remove-sendpage.patch [new file with mode: 0644]

index 1083d6ec78bb64a49f0644a8ddb030b5288d2297..969d27f5a8d38e0632f7f66048b11b2e0c94ae9d 100644 (file)
@@ -9,13 +9,13 @@ include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=libpfring
-PKG_VERSION:=8.4.0
-PKG_RELEASE:=2
+PKG_VERSION:=8.6.1
+PKG_RELEASE:=1
 
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
-PKG_SOURCE_URL:=https://codeload.github.com/ntop/PF_RING/tar.gz/$(PKG_VERSION)?
-PKG_HASH:=2756a45ab250da11850160beb62aa879075aedfb49bf8f323b404f02b0c36670
-PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/PF_RING-$(PKG_VERSION)
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_VERSION:=$(PKG_VERSION)
+PKG_SOURCE_URL:=https://github.com/ntop/PF_RING
+PKG_MIRROR_HASH:=2c4623e4a3cd601a94cfdaf748e0cd7aa93e8ec850d3cd4c2ec5d33419e45fbb
 
 PKG_MAINTAINER:=Banglang Huang <banglang.huang@foxmail.com>
 
index 021162bbbfa4e64ec91e0b6a77f6aab3a6afcd82..1b9d455408eed55b3caec2c29b6a1115d0bff63f 100644 (file)
@@ -1,6 +1,6 @@
 --- a/userland/configure
 +++ b/userland/configure
-@@ -3868,12 +3868,6 @@ $as_echo "no" >&6; }
+@@ -3873,12 +3873,6 @@ $as_echo "no" >&6; }
          if test "$IS_FREEBSD" != "1" && test "$cross_compiling" != "yes" ; then
        { $as_echo "$as_me:${as_lineno-$LINENO}: checking if r/w locks are supported" >&5
  $as_echo_n "checking if r/w locks are supported... " >&6; }
@@ -13,7 +13,7 @@
    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
  /* end confdefs.h.  */
  
-@@ -3886,7 +3880,7 @@ else
+@@ -3891,7 +3885,7 @@ else
  
  
  _ACEOF
@@ -22,7 +22,7 @@
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
  $as_echo "yes" >&6; }
  cat >>confdefs.h <<_ACEOF
-@@ -3900,7 +3894,6 @@ $as_echo "no" >&6; }
+@@ -3905,7 +3899,6 @@ $as_echo "no" >&6; }
  fi
  rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
    conftest.$ac_objext conftest.beam conftest.$ac_ext
diff --git a/libs/libpfring/patches/002-implement-probabilistic-sampling.patch b/libs/libpfring/patches/002-implement-probabilistic-sampling.patch
deleted file mode 100644 (file)
index d7b3e83..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-From 405caa1424358032574230ec5479e64834869298 Mon Sep 17 00:00:00 2001
-From: Alfredo Cardigliano <cardigliano@ntop.org>
-Date: Thu, 13 Apr 2023 13:03:28 +0200
-Subject: [PATCH] Implement probabilistic sampling
-
----
- kernel/linux/pf_ring.h |  4 +++-
- kernel/pf_ring.c       | 34 ++++++++++++++++++++++++----------
- 2 files changed, 27 insertions(+), 11 deletions(-)
-
---- a/kernel/linux/pf_ring.h
-+++ b/kernel/linux/pf_ring.h
-@@ -1310,7 +1310,9 @@ struct pf_ring_socket {
-   u_char *ring_slots;       /* Points to ring_memory+sizeof(FlowSlotInfo) */
-   /* Packet Sampling */
--  u_int32_t pktToSample, sample_rate;
-+  u_int32_t sample_rate;
-+  u_int32_t pkts_to_sample;
-+  u_int32_t sample_rnd_shift;
-   /* Virtual Filtering Device */
-   virtual_filtering_device_element *v_filtering_dev;
---- a/kernel/pf_ring.c
-+++ b/kernel/pf_ring.c
-@@ -3695,6 +3695,26 @@ int bpf_filter_skb(struct sk_buff *skb,
- /* ********************************** */
-+int sample_packet(struct pf_ring_socket *pfr) {
-+  if(pfr->pkts_to_sample <= 1) {
-+    u_int32_t rnd = 0;
-+
-+    get_random_bytes(&rnd, sizeof(u_int32_t));
-+    rnd = rnd % pfr->sample_rate;
-+
-+    pfr->pkts_to_sample = pfr->sample_rate - pfr->sample_rnd_shift + rnd;
-+
-+    pfr->sample_rnd_shift = rnd;
-+
-+    return 1; /* Pass packet */
-+  } else {
-+    pfr->pkts_to_sample--;
-+    return 0; /* Discard packet */
-+  }
-+}
-+
-+/* ********************************** */
-+
- u_int32_t default_rehash_rss_func(struct sk_buff *skb, struct pfring_pkthdr *hdr)
- {
-   return hash_pkt_header(hdr, 0);
-@@ -3805,12 +3825,9 @@ static int add_skb_to_ring(struct sk_buf
-     if(pfr->sample_rate > 1) {
-       spin_lock_bh(&pfr->ring_index_lock);
--      if(pfr->pktToSample <= 1) {
--      pfr->pktToSample = pfr->sample_rate;
--      } else {
-+      if(!sample_packet(pfr)) {
-+        /* Discard packet */
-         pfr->slots_info->tot_pkts++;
--      pfr->pktToSample--;
--
-       spin_unlock_bh(&pfr->ring_index_lock);
-       atomic_dec(&pfr->num_ring_users);
-       return(-1);
-@@ -4161,11 +4178,8 @@ int pf_ring_skb_ring_handler(struct sk_b
-         if(pfr->sample_rate > 1) {
-           spin_lock_bh(&pfr->ring_index_lock);
--          if(pfr->pktToSample <= 1) {
--            pfr->pktToSample = pfr->sample_rate;
--          } else {
-+          if (!sample_packet(pfr)) {
-             pfr->slots_info->tot_pkts++;
--            pfr->pktToSample--;
-             rc = 0;
-           }
-           spin_unlock_bh(&pfr->ring_index_lock);
-@@ -7957,7 +7971,7 @@ static int ring_getsockopt(struct socket
-       if(copy_to_user(optval, lowest_if_mac, ETH_ALEN))
-         return(-EFAULT);
-       } else {
--        char *dev_addr = pfr->ring_dev->dev->dev_addr;
-+        const char *dev_addr = pfr->ring_dev->dev->dev_addr;
-         if (dev_addr == NULL) /* e.g. 'any' device */
-           dev_addr = empty_mac;
diff --git a/libs/libpfring/patches/010-gcc14.patch b/libs/libpfring/patches/010-gcc14.patch
new file mode 100644 (file)
index 0000000..c17dc85
--- /dev/null
@@ -0,0 +1,24 @@
+--- a/kernel/pf_ring.c
++++ b/kernel/pf_ring.c
+@@ -4713,8 +4713,8 @@ void reserve_memory(unsigned long base,
+ {
+   struct page *page, *page_end;
+-  page_end = virt_to_page(base + mem_len - 1);
+-  for(page = virt_to_page(base); page <= page_end; page++)
++  page_end = virt_to_page((void*)base + mem_len - 1);
++  for(page = virt_to_page((void*)base); page <= page_end; page++)
+     SetPageReserved(page);
+ }
+@@ -4722,8 +4722,8 @@ void unreserve_memory(unsigned long base
+ {
+   struct page *page, *page_end;
+-  page_end = virt_to_page(base + mem_len - 1);
+-  for(page = virt_to_page(base); page <= page_end; page++)
++  page_end = virt_to_page((void*)base + mem_len - 1);
++  for(page = virt_to_page((void*)base); page <= page_end; page++)
+     ClearPageReserved(page);
+ }
index 97115b1761a778588c882736450317dc598ae650..85393a2efbd851e216b35762c0d687e3e96d20d1 100644 (file)
@@ -1,6 +1,6 @@
 --- a/kernel/pf_ring.c
 +++ b/kernel/pf_ring.c
-@@ -3902,7 +3902,7 @@ static int hash_pkt_cluster(ring_cluster
+@@ -3903,7 +3903,7 @@ static int hash_pkt_cluster(ring_cluster
        break;
      }
      /* else, fall through, because it's like 2-tuple for non-TCP packets */
index 7c27515f4c0a7b8266d1bff40f281e98b090d2cf..3045818fcf32a109390f6df090158998e512939d 100644 (file)
@@ -1,4 +1,4 @@
-From fae2437c2af80d3ea64f5bc9678a5b697772295b Mon Sep 17 00:00:00 2001
+From 1b7780e9ecb46c6a5bbc8a831778a683f8ae80d8 Mon Sep 17 00:00:00 2001
 From: Christian Marangi <ansuelsmth@gmail.com>
 Date: Mon, 18 Mar 2024 10:03:43 +0100
 Subject: [PATCH] kernel: pf_ring: better define sa_data size
@@ -18,12 +18,12 @@ handling more deterministic.
 
 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
 ---
- kernel/pf_ring.c | 22 ++++++++++++++++++----
- 1 file changed, 18 insertions(+), 4 deletions(-)
+ kernel/pf_ring.c | 2++++++++++++++++----
+ 1 file changed, 16 insertions(+), 4 deletions(-)
 
 --- a/kernel/pf_ring.c
 +++ b/kernel/pf_ring.c
-@@ -155,6 +155,18 @@
+@@ -158,6 +158,18 @@
  #endif
  #endif
  
@@ -42,19 +42,19 @@ Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
  /* ************************************************* */
  
  #if(LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0))
-@@ -1029,7 +1041,7 @@ pf_ring_device *pf_ring_device_name_look
-         so the total interface name length is 13 chars (plus \0 trailer).
-         The check below is to trap this case.
-        */
--      || ((l >= 13) && (strncmp(dev_ptr->device_name, name, 13) == 0)))
-+      || ((l >= RING_SA_DATA_LEN - 1) && (strncmp(dev_ptr->device_name, name, RING_SA_DATA_LEN - 1) == 0)))
+@@ -1032,7 +1044,7 @@ pf_ring_device *pf_ring_device_name_look
+           so the total interface name length is 13 chars (plus \0 trailer).
+           The check below is to trap this case.
+          */
+-        || ((l >= 13) && (strncmp(dev_ptr->device_name, name, 13) == 0)))
++        || ((l >= RING_SA_DATA_LEN - 1) && (strncmp(dev_ptr->device_name, name, RING_SA_DATA_LEN - 1) == 0)))
         && device_net_eq(dev_ptr, net))
        return dev_ptr;
    }
-@@ -5571,15 +5583,15 @@ static int ring_bind(struct socket *sock
-    * Check legality
-    */
-   if (addr_len == sizeof(struct sockaddr)) {
+@@ -5605,15 +5617,15 @@ static int ring_bind(struct socket *sock
+ #ifndef RING_USE_SOCKADDR_LL
+   } else if (addr_len == sizeof(struct sockaddr)) { /* Deprecated */
 -    char name[sizeof(sa->sa_data)+1];
 +    char name[RING_SA_DATA_LEN];
  
diff --git a/libs/libpfring/patches/102-remove-sendpage.patch b/libs/libpfring/patches/102-remove-sendpage.patch
new file mode 100644 (file)
index 0000000..a5ca509
--- /dev/null
@@ -0,0 +1,22 @@
+From 5557b6ffe8d4eeb93532d043649b40eb10120bf7 Mon Sep 17 00:00:00 2001
+From: Gavin <gavin.bravery@jagsiacs.co.uk>
+Date: Wed, 25 Oct 2023 11:40:50 +0100
+Subject: [PATCH] Update pf_ring.c
+
+Change to remove .sendpage assignment, as that attribute seems to have gone away in 6.5.3 kernel.
+---
+ kernel/pf_ring.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/kernel/pf_ring.c
++++ b/kernel/pf_ring.c
+@@ -8470,7 +8470,9 @@ static struct proto_ops ring_ops = {
+   .getname = sock_no_getname,
+   .listen = sock_no_listen,
+   .shutdown = sock_no_shutdown,
++  #if(LINUX_VERSION_CODE < KERNEL_VERSION(6,5,3))
+   .sendpage = sock_no_sendpage,
++  #endif
+   /* Now the operations that really occur. */
+   .release = ring_release,