110-ipset-remove-old-kernel-support.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #define NL_ALIGN(len) (((len)+3) & ~(3))
  13. static const struct sockaddr_nl snl = { .nl_family = AF_NETLINK };
  14. -static int ipset_sock, old_kernel;
  15. +static int ipset_sock;
  16. static char *buffer;
  17. static inline void add_attr(struct nlmsghdr *nlh, uint16_t type, size_t len, const void *data)
  18. @@ -87,25 +86,7 @@ static inline void add_attr(struct nlmsg
  19. void ipset_init(void)
  20. {
  21. - struct utsname utsname;
  22. - int version;
  23. - char *split;
  24. -
  25. - if (uname(&utsname) < 0)
  26. - die(_("failed to find kernel version: %s"), NULL, EC_MISC);
  27. -
  28. - split = strtok(utsname.release, ".");
  29. - version = (split ? atoi(split) : 0);
  30. - split = strtok(NULL, ".");
  31. - version = version * 256 + (split ? atoi(split) : 0);
  32. - split = strtok(NULL, ".");
  33. - version = version * 256 + (split ? atoi(split) : 0);
  34. - old_kernel = (version < KERNEL_VERSION(2,6,32));
  35. -
  36. - if (old_kernel && (ipset_sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) != -1)
  37. - return;
  38. -
  39. - if (!old_kernel &&
  40. + if (
  41. (buffer = safe_malloc(BUFF_SZ)) &&
  42. (ipset_sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_NETFILTER)) != -1 &&
  43. (bind(ipset_sock, (struct sockaddr *)&snl, sizeof(snl)) != -1))
  44. @@ -211,16 +192,9 @@ int add_to_ipset(const char *setname, co
  45. if (flags & F_IPV6)
  46. {
  47. af = AF_INET6;
  48. - /* old method only supports IPv4 */
  49. - if (old_kernel)
  50. - {
  51. - errno = EAFNOSUPPORT ;
  52. - ret = -1;
  53. - }
  54. }
  55. - if (ret != -1)
  56. - ret = old_kernel ? old_add_to_ipset(setname, ipaddr, remove) : new_add_to_ipset(setname, ipaddr, af, remove);
  57. + ret = new_add_to_ipset(setname, ipaddr, af, remove);
  58. if (ret == -1)
  59. my_syslog(LOG_ERR, _("failed to update ipset %s: %s"), setname, strerror(errno));