summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2019-04-19 10:52:54 +0000
committerKristof Provost <kp@FreeBSD.org>2019-04-19 10:52:54 +0000
commit7296d6c9bf670dc48c14ec2dff9eb3a044f12c5e (patch)
tree09a0fd06dda3aa88ecd3c5530820155dc2952e0c
parent5ddaf8458e187cbb3ea5330f36861df5b31358b8 (diff)
Notes
-rw-r--r--sbin/pfctl/pfctl_optimize.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/sbin/pfctl/pfctl_optimize.c b/sbin/pfctl/pfctl_optimize.c
index 7d4381d39524..599ed2424ebf 100644
--- a/sbin/pfctl/pfctl_optimize.c
+++ b/sbin/pfctl/pfctl_optimize.c
@@ -1500,14 +1500,24 @@ superblock_inclusive(struct superblock *block, struct pf_opt_rule *por)
int
interface_group(const char *ifname)
{
+ int s;
+ struct ifgroupreq ifgr;
+
if (ifname == NULL || !ifname[0])
return (0);
- /* Real interfaces must end in a number, interface groups do not */
- if (isdigit(ifname[strlen(ifname) - 1]))
- return (0);
- else
- return (1);
+ s = get_query_socket();
+
+ memset(&ifgr, 0, sizeof(ifgr));
+ strlcpy(ifgr.ifgr_name, ifname, IFNAMSIZ);
+ if (ioctl(s, SIOCGIFGMEMB, (caddr_t)&ifgr) == -1) {
+ if (errno == ENOENT)
+ return (0);
+ else
+ err(1, "SIOCGIFGMEMB");
+ }
+
+ return (1);
}