Merge pull request #559 from wigyori/cc-misc2
[15.05/openwrt.git] / package / network / services / dnsmasq / patches / 110-ipset-remove-old-kernel-support.patch
1 --- a/src/ipset.c
2 +++ b/src/ipset.c
3 @@ -22,7 +22,6 @@
4  #include <errno.h>
5  #include <sys/types.h>
6  #include <sys/socket.h>
7 -#include <sys/utsname.h>
8  #include <arpa/inet.h>
9  #include <linux/version.h>
10  #include <linux/netlink.h>
11 @@ -72,7 +71,7 @@ struct my_nfgenmsg {
12  
13  #define NL_ALIGN(len) (((len)+3) & ~(3))
14  static const struct sockaddr_nl snl = { .nl_family = AF_NETLINK };
15 -static int ipset_sock, old_kernel;
16 +static int ipset_sock;
17  static char *buffer;
18  
19  static inline void add_attr(struct nlmsghdr *nlh, uint16_t type, size_t len, const void *data)
20 @@ -87,25 +86,7 @@ static inline void add_attr(struct nlmsg
21  
22  void ipset_init(void)
23  {
24 -  struct utsname utsname;
25 -  int version;
26 -  char *split;
27 -  
28 -  if (uname(&utsname) < 0)
29 -    die(_("failed to find kernel version: %s"), NULL, EC_MISC);
30 -  
31 -  split = strtok(utsname.release, ".");
32 -  version = (split ? atoi(split) : 0);
33 -  split = strtok(NULL, ".");
34 -  version = version * 256 + (split ? atoi(split) : 0);
35 -  split = strtok(NULL, ".");
36 -  version = version * 256 + (split ? atoi(split) : 0);
37 -  old_kernel = (version < KERNEL_VERSION(2,6,32));
38 -  
39 -  if (old_kernel && (ipset_sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) != -1)
40 -    return;
41 -  
42 -  if (!old_kernel && 
43 +  if ( 
44        (buffer = safe_malloc(BUFF_SZ)) &&
45        (ipset_sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_NETFILTER)) != -1 &&
46        (bind(ipset_sock, (struct sockaddr *)&snl, sizeof(snl)) != -1))
47 @@ -217,17 +198,10 @@ int add_to_ipset(const char *setname, co
48    if (flags & F_IPV6)
49      {
50        af = AF_INET6;
51 -      /* old method only supports IPv4 */
52 -      if (old_kernel)
53 -       {
54 -         errno = EAFNOSUPPORT ;
55 -         ret = -1;
56 -       }
57      }
58  #endif
59    
60 -  if (ret != -1) 
61 -    ret = old_kernel ? old_add_to_ipset(setname, ipaddr, remove) : new_add_to_ipset(setname, ipaddr, af, remove);
62 +    ret = new_add_to_ipset(setname, ipaddr, af, remove);
63  
64    if (ret == -1)
65       my_syslog(LOG_ERR, _("failed to update ipset %s: %s"), setname, strerror(errno));