iface: some command decoupling

This commit is contained in:
Jan Engelhardt
2009-04-26 21:56:53 +02:00
parent e1fc5f2086
commit 0d36136f54
2 changed files with 5 additions and 5 deletions

View File

@@ -62,7 +62,7 @@ static bool iface_valid_name(const char *name)
{ {
char invalid_chars[] = ".+!*"; char invalid_chars[] = ".+!*";
return !(strlen(name) >= IFNAMSIZ || strcspn(name, invalid_chars) != strlen(name)); return strlen(name) < IFNAMSIZ && strpbrk(name, invalid_chars) == NULL;
} }
static void iface_mt_help(void) static void iface_mt_help(void)

View File

@@ -42,14 +42,14 @@ static bool xt_iface_mt(const struct sk_buff *skb,
bool retval; bool retval;
int i; int i;
retval = dev = dev_get_by_name(&init_net, info->ifname);
(dev = dev_get_by_name(&init_net, info->ifname)) != NULL; retval = dev != NULL;
if (retval) { if (retval) {
for (i = 0; i < XT_IFACE_FLAGCOUNT && retval; ++i) { for (i = 0; i < XT_IFACE_FLAGCOUNT && retval; ++i) {
if (info->flags & xt_iface_lookup[i].iface_flag) if (info->flags & xt_iface_lookup[i].iface_flag)
retval = retval && (dev->flags & xt_iface_lookup[i].iff_flag); retval &= dev->flags & xt_iface_lookup[i].iff_flag;
if (info->invflags & xt_iface_lookup[i].iface_flag) if (info->invflags & xt_iface_lookup[i].iface_flag)
retval = retval && !(dev->flags & xt_iface_lookup[i].iff_flag); retval &= !(dev->flags & xt_iface_lookup[i].iff_flag);
} }
dev_put(dev); dev_put(dev);
} }