ASR_BASE

Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/external/subpack/libs/libpfring/patches/0001-fix-cross-compiling.patch b/external/subpack/libs/libpfring/patches/0001-fix-cross-compiling.patch
new file mode 100644
index 0000000..1b9d455
--- /dev/null
+++ b/external/subpack/libs/libpfring/patches/0001-fix-cross-compiling.patch
@@ -0,0 +1,32 @@
+--- a/userland/configure
++++ b/userland/configure
+@@ -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; }
+-      if test "$cross_compiling" = yes; then :
+-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+-as_fn_error $? "cannot run test program while cross compiling
+-See \`config.log' for more details" "$LINENO" 5; }
+-else
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h.  */
+ 
+@@ -3891,7 +3885,7 @@ else
+ 
+ 
+ _ACEOF
+-if ac_fn_c_try_run "$LINENO"; then :
++if ac_fn_c_try_compile "$LINENO"; then :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ $as_echo "yes" >&6; }
+ cat >>confdefs.h <<_ACEOF
+@@ -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
+-fi
+ 
+     fi
+ 
diff --git a/external/subpack/libs/libpfring/patches/010-gcc14.patch b/external/subpack/libs/libpfring/patches/010-gcc14.patch
new file mode 100644
index 0000000..c17dc85
--- /dev/null
+++ b/external/subpack/libs/libpfring/patches/010-gcc14.patch
@@ -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);
+ }
+ 
diff --git a/external/subpack/libs/libpfring/patches/100-fix-compilation-warning.patch b/external/subpack/libs/libpfring/patches/100-fix-compilation-warning.patch
new file mode 100644
index 0000000..85393a2
--- /dev/null
+++ b/external/subpack/libs/libpfring/patches/100-fix-compilation-warning.patch
@@ -0,0 +1,11 @@
+--- a/kernel/pf_ring.c
++++ b/kernel/pf_ring.c
+@@ -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 */
+-
++    fallthrough;
+   case cluster_per_flow_2_tuple:
+   case cluster_per_inner_flow_2_tuple:
+     flags |= mask_2_tuple;
diff --git a/external/subpack/libs/libpfring/patches/101-kernel-pf_ring-better-define-sa_data-size.patch b/external/subpack/libs/libpfring/patches/101-kernel-pf_ring-better-define-sa_data-size.patch
new file mode 100644
index 0000000..3045818
--- /dev/null
+++ b/external/subpack/libs/libpfring/patches/101-kernel-pf_ring-better-define-sa_data-size.patch
@@ -0,0 +1,72 @@
+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
+
+pfring_mod_bind() needs to specify the interface
+name using struct sockaddr that is defined as
+
+struct sockaddr { ushort sa_family; char sa_data[14]; };
+
+so the total interface name length is 13 chars (plus \0 trailer).
+
+Since sa_data size is arbitrary, define a more precise size for
+PF_RING socket use.
+
+This fix some compilation error with fortify string and makes the array
+handling more deterministic.
+
+Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
+---
+ kernel/pf_ring.c | 20 ++++++++++++++++----
+ 1 file changed, 16 insertions(+), 4 deletions(-)
+
+--- a/kernel/pf_ring.c
++++ b/kernel/pf_ring.c
+@@ -158,6 +158,18 @@
+ #endif
+ #endif
+ 
++/*
++  pfring_mod_bind() needs to specify the interface
++	name using struct sockaddr that is defined as
++
++  struct sockaddr { ushort sa_family; char sa_data[14]; };
++
++  so the total interface name length is 13 chars (plus \0 trailer).
++  Since sa_data size is arbitrary, define a more precise size for
++  PF_RING socket use.
++*/
++#define RING_SA_DATA_LEN 14
++
+ /* ************************************************* */
+ 
+ #if(LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,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;
+   }
+@@ -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];
+ 
+     if (sa->sa_family != PF_RING)
+       return(-EINVAL);
+ 
+-    memcpy(name, sa->sa_data, sizeof(sa->sa_data));
++    memcpy(name, sa->sa_data, RING_SA_DATA_LEN - 1);
+ 
+     /* Add trailing zero if missing */
+-    name[sizeof(name)-1] = '\0';
++    name[RING_SA_DATA_LEN-1] = '\0';
+ 
+     debug_printk(2, "searching device %s\n", name);
+ 
diff --git a/external/subpack/libs/libpfring/patches/102-remove-sendpage.patch b/external/subpack/libs/libpfring/patches/102-remove-sendpage.patch
new file mode 100644
index 0000000..a5ca509
--- /dev/null
+++ b/external/subpack/libs/libpfring/patches/102-remove-sendpage.patch
@@ -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,