summaryrefslogtreecommitdiff
path: root/package/network/services/dnsmasq/patches/110-ipset-remove-old-kernel-support.patch
blob: 61b09d5b2c95d4bf57e86cdd75c7f1e52ba04e44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
--- a/src/ipset.c
+++ b/src/ipset.c
@@ -22,7 +22,6 @@
 #include <errno.h>
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <sys/utsname.h>
 #include <arpa/inet.h>
 #include <linux/version.h>
 #include <linux/netlink.h>
@@ -72,7 +71,7 @@ struct my_nfgenmsg {
 
 #define NL_ALIGN(len) (((len)+3) & ~(3))
 static const struct sockaddr_nl snl = { .nl_family = AF_NETLINK };
-static int ipset_sock, old_kernel;
+static int ipset_sock;
 static char *buffer;
 
 static inline void add_attr(struct nlmsghdr *nlh, uint16_t type, size_t len, const void *data)
@@ -87,25 +86,7 @@ static inline void add_attr(struct nlmsg
 
 void ipset_init(void)
 {
-  struct utsname utsname;
-  int version;
-  char *split;
-  
-  if (uname(&utsname) < 0)
-    die(_("failed to find kernel version: %s"), NULL, EC_MISC);
-  
-  split = strtok(utsname.release, ".");
-  version = (split ? atoi(split) : 0);
-  split = strtok(NULL, ".");
-  version = version * 256 + (split ? atoi(split) : 0);
-  split = strtok(NULL, ".");
-  version = version * 256 + (split ? atoi(split) : 0);
-  old_kernel = (version < KERNEL_VERSION(2,6,32));
-  
-  if (old_kernel && (ipset_sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) != -1)
-    return;
-  
-  if (!old_kernel && 
+  if ( 
       (buffer = safe_malloc(BUFF_SZ)) &&
       (ipset_sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_NETFILTER)) != -1 &&
       (bind(ipset_sock, (struct sockaddr *)&snl, sizeof(snl)) != -1))
@@ -168,62 +149,16 @@ static int new_add_to_ipset(const char *
 }
 
 
-static int old_add_to_ipset(const char *setname, const struct all_addr *ipaddr, int remove)
-{
-  socklen_t size;
-  struct ip_set_req_adt_get {
-    unsigned op;
-    unsigned version;
-    union {
-      char name[IPSET_MAXNAMELEN];
-      uint16_t index;
-    } set;
-    char typename[IPSET_MAXNAMELEN];
-  } req_adt_get;
-  struct ip_set_req_adt {
-    unsigned op;
-    uint16_t index;
-    uint32_t ip;
-  } req_adt;
-  
-  if (strlen(setname) >= sizeof(req_adt_get.set.name)) 
-    {
-      errno = ENAMETOOLONG;
-      return -1;
-    }
-  
-  req_adt_get.op = 0x10;
-  req_adt_get.version = 3;
-  strcpy(req_adt_get.set.name, setname);
-  size = sizeof(req_adt_get);
-  if (getsockopt(ipset_sock, SOL_IP, 83, &req_adt_get, &size) < 0)
-    return -1;
-  req_adt.op = remove ? 0x102 : 0x101;
-  req_adt.index = req_adt_get.set.index;
-  req_adt.ip = ntohl(ipaddr->addr.addr4.s_addr);
-  if (setsockopt(ipset_sock, SOL_IP, 83, &req_adt, sizeof(req_adt)) < 0)
-    return -1;
-  
-  return 0;
-}
-
-
-
 int add_to_ipset(const char *setname, const struct all_addr *ipaddr, int flags, int remove)
 {
   int af = AF_INET;
 
 #ifdef HAVE_IPV6
   if (flags & F_IPV6)
-    {
       af = AF_INET6;
-      /* old method only supports IPv4 */
-      if (old_kernel)
-	return -1;
-    }
 #endif
   
-  return old_kernel ? old_add_to_ipset(setname, ipaddr, remove) : new_add_to_ipset(setname, ipaddr, af, remove);
+  return new_add_to_ipset(setname, ipaddr, af, remove);
 }
 
 #endif