Fix "iptables getsockopt failed strangely" when querying revisions for non-existant matches and targets
Reported by Joseph Jezak <josejx@gentoo.org>.
diff --git a/ip6tables.c b/ip6tables.c
index f316c7a..6b2766b 100644
--- a/ip6tables.c
+++ b/ip6tables.c
@@ -1130,7 +1130,7 @@
max_rev = getsockopt(sockfd, IPPROTO_IPV6, opt, &rev, &s);
if (max_rev < 0) {
/* Definitely don't support this? */
- if (errno == EPROTONOSUPPORT) {
+ if (errno == ENOENT || errno == EPROTONOSUPPORT) {
close(sockfd);
return 0;
} else if (errno == ENOPROTOOPT) {
diff --git a/iptables.c b/iptables.c
index 893b02d..83b0c82 100644
--- a/iptables.c
+++ b/iptables.c
@@ -1158,7 +1158,7 @@
max_rev = getsockopt(sockfd, IPPROTO_IP, opt, &rev, &s);
if (max_rev < 0) {
/* Definitely don't support this? */
- if (errno == EPROTONOSUPPORT) {
+ if (errno == ENOENT || errno == EPROTONOSUPPORT) {
close(sockfd);
return 0;
} else if (errno == ENOPROTOOPT) {