Author: Jaret Cantu <jaret.cantu@timesys.com>
Date:   Thu Nov 30 11:06:08 EST 2017

    Define kernel types and values for older Linux versions

diff -Naur iproute2-5.18.0.orig/include/uapi/linux/sysinfo.h iproute2-5.18.0/include/uapi/linux/sysinfo.h
--- iproute2-5.18.0.orig/include/uapi/linux/sysinfo.h	2022-05-27 04:21:48.000000000 +0530
+++ iproute2-5.18.0/include/uapi/linux/sysinfo.h	2022-07-15 14:26:44.546915520 +0530
@@ -3,6 +3,14 @@
 #define _LINUX_SYSINFO_H
 
 #include <linux/types.h>
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
+#ifndef __kernel_long_t
+typedef long		__kernel_long_t;
+typedef unsigned long	__kernel_ulong_t;
+#endif
+#endif
 
 #define SI_LOAD_SHIFT	16
 struct sysinfo {
diff -Naur iproute2-5.18.0.orig/lib/bpf_legacy.c iproute2-5.18.0/lib/bpf_legacy.c
--- iproute2-5.18.0.orig/lib/bpf_legacy.c	2022-05-27 04:21:48.000000000 +0530
+++ iproute2-5.18.0/lib/bpf_legacy.c	2022-07-15 14:59:00.815579385 +0530
@@ -45,6 +45,18 @@
 #include "bpf_elf.h"
 #include "bpf_scm.h"
 
+#ifndef MS_BIND
+#define MS_BIND	4096
+#endif
+
+#ifndef MS_REC
+#define MS_REC		16384
+#endif
+
+#ifndef MS_PRIVATE
+#define MS_PRIVATE	(1<<18) /* change to private */
+#endif
+
 struct bpf_prog_meta {
 	const char *type;
 	const char *subdir;
diff -Naur iproute2-5.18.0.orig/misc/ss.c iproute2-5.18.0/misc/ss.c
--- iproute2-5.18.0.orig/misc/ss.c	2022-05-27 04:21:48.000000000 +0530
+++ iproute2-5.18.0/misc/ss.c	2022-07-15 14:59:56.055449994 +0530
@@ -109,6 +109,15 @@
 }
 #endif
 
+#ifndef AF_VSOCK
+#define AF_VSOCK 40
+#endif
+
+#if AF_MAX <= AF_VSOCK
+#undef AF_MAX
+#define AF_MAX ((AF_VSOCK)+1)
+#endif
+
 int preferred_family = AF_UNSPEC;
 static int show_options;
 int show_details;
 
diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h
index ef38c2b..d206459 100644
--- a/include/uapi/linux/elf-em.h
+++ b/include/uapi/linux/elf-em.h
@@ -63,7 +63,9 @@
 /* Bogus old m32r magic number, used by old tools. */
 #define EM_CYGNUS_M32R	0x9041
 /* This is the old interim value for S/390 architecture */
-#define EM_S390_OLD	0xA390
+#ifndef EM_S390_OLD
+#define EM_S390_OLD 0xA390
+#endif
 /* Also Panasonic/MEI MN10300, AM33 */
 #define EM_CYGNUS_MN10300 0xbeef
 
diff --git a/include/uapi/linux/ppp_defs.h b/include/uapi/linux/ppp_defs.h
index b2cbb3b..3d6237d 100644
--- a/include/uapi/linux/ppp_defs.h
+++ b/include/uapi/linux/ppp_defs.h
@@ -67,6 +67,18 @@
 #define PPP_INITFCS	0xffff	/* Initial FCS value */
 #define PPP_GOODFCS	0xf0b8	/* Good final FCS value */
 
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
+#ifndef __kernel_long_t
+typedef long		__kernel_long_t;
+typedef unsigned long	__kernel_ulong_t;
+#endif
+#endif
+
+#ifndef __kernel_old_time_t
+typedef __kernel_long_t	__kernel_old_time_t;
+#endif
 
 /*
  * Extended asyncmap - allows any character to be escaped.
