]> granicus.if.org Git - ipset/commitdiff
netfilter: ipset: Check IPSET_ATTR_PORT only once
authorSergey Popovich <popovich_sergei@mail.ua>
Mon, 17 Nov 2014 15:08:37 +0000 (17:08 +0200)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Fri, 20 Mar 2015 18:01:02 +0000 (19:01 +0100)
We do not need to check tb[IPSET_ATTR_PORT] != NULL before
retrieving port, as this attribute is known to exist due to
ip_set_attr_netorder() returning true only when attribute
exists and it is in network byte order.

Signed-off-by: Sergey Popovich <popovich_sergei@mail.ua>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
kernel/net/netfilter/ipset/ip_set_hash_ipport.c
kernel/net/netfilter/ipset/ip_set_hash_ipportip.c
kernel/net/netfilter/ipset/ip_set_hash_ipportnet.c
kernel/net/netfilter/ipset/ip_set_hash_netport.c
kernel/net/netfilter/ipset/ip_set_hash_netportnet.c

index 6ae62d5117fac494a68abbb629275ca3aa5c9192..8646fa1b78d4cca1ecbedcd180e60bfaad913268 100644 (file)
@@ -133,10 +133,7 @@ hash_ipport4_uadt(struct ip_set *set, struct nlattr *tb[],
        if (ret)
                return ret;
 
-       if (tb[IPSET_ATTR_PORT])
-               e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
-       else
-               return -IPSET_ERR_PROTOCOL;
+       e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
 
        if (tb[IPSET_ATTR_PROTO]) {
                e.proto = nla_get_u8(tb[IPSET_ATTR_PROTO]);
@@ -298,10 +295,7 @@ hash_ipport6_uadt(struct ip_set *set, struct nlattr *tb[],
        if (ret)
                return ret;
 
-       if (tb[IPSET_ATTR_PORT])
-               e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
-       else
-               return -IPSET_ERR_PROTOCOL;
+       e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
 
        if (tb[IPSET_ATTR_PROTO]) {
                e.proto = nla_get_u8(tb[IPSET_ATTR_PROTO]);
index 1af379a756ecf79cddeb1aa3fff0434cc77fc0a7..4c03457020400e6fb6b01b74f4f20c266d67cb13 100644 (file)
@@ -139,10 +139,7 @@ hash_ipportip4_uadt(struct ip_set *set, struct nlattr *tb[],
        if (ret)
                return ret;
 
-       if (tb[IPSET_ATTR_PORT])
-               e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
-       else
-               return -IPSET_ERR_PROTOCOL;
+       e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
 
        if (tb[IPSET_ATTR_PROTO]) {
                e.proto = nla_get_u8(tb[IPSET_ATTR_PROTO]);
@@ -310,10 +307,7 @@ hash_ipportip6_uadt(struct ip_set *set, struct nlattr *tb[],
        if (ret)
                return ret;
 
-       if (tb[IPSET_ATTR_PORT])
-               e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
-       else
-               return -IPSET_ERR_PROTOCOL;
+       e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
 
        if (tb[IPSET_ATTR_PROTO]) {
                e.proto = nla_get_u8(tb[IPSET_ATTR_PROTO]);
index 5e0462723be5654c814876c8e85790488bf71f35..03ffd81deccc52affb4f221279e4d606a992f539 100644 (file)
@@ -201,10 +201,7 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
                e.cidr = cidr - 1;
        }
 
-       if (tb[IPSET_ATTR_PORT])
-               e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
-       else
-               return -IPSET_ERR_PROTOCOL;
+       e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
 
        if (tb[IPSET_ATTR_PROTO]) {
                e.proto = nla_get_u8(tb[IPSET_ATTR_PROTO]);
@@ -460,10 +457,7 @@ hash_ipportnet6_uadt(struct ip_set *set, struct nlattr *tb[],
 
        ip6_netmask(&e.ip2, e.cidr + 1);
 
-       if (tb[IPSET_ATTR_PORT])
-               e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
-       else
-               return -IPSET_ERR_PROTOCOL;
+       e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
 
        if (tb[IPSET_ATTR_PROTO]) {
                e.proto = nla_get_u8(tb[IPSET_ATTR_PROTO]);
index b2ada7e7794fa23cbb361de83b7300fb1540efe6..0196e40c76a89e7bc453b42490da34888c0fadaf 100644 (file)
@@ -190,10 +190,7 @@ hash_netport4_uadt(struct ip_set *set, struct nlattr *tb[],
                e.cidr = cidr - 1;
        }
 
-       if (tb[IPSET_ATTR_PORT])
-               e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
-       else
-               return -IPSET_ERR_PROTOCOL;
+       e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
 
        if (tb[IPSET_ATTR_PROTO]) {
                e.proto = nla_get_u8(tb[IPSET_ATTR_PROTO]);
@@ -411,10 +408,7 @@ hash_netport6_uadt(struct ip_set *set, struct nlattr *tb[],
        }
        ip6_netmask(&e.ip, e.cidr + 1);
 
-       if (tb[IPSET_ATTR_PORT])
-               e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
-       else
-               return -IPSET_ERR_PROTOCOL;
+       e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
 
        if (tb[IPSET_ATTR_PROTO]) {
                e.proto = nla_get_u8(tb[IPSET_ATTR_PROTO]);
index e3bcc7554d8194f19334e7530d5daf636a70df0f..2b4c4e2703b1d7bb601027e128d152ac34d888e3 100644 (file)
@@ -219,10 +219,7 @@ hash_netportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
                e.cidr[1] = cidr;
        }
 
-       if (tb[IPSET_ATTR_PORT])
-               e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
-       else
-               return -IPSET_ERR_PROTOCOL;
+       e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
 
        if (tb[IPSET_ATTR_PROTO]) {
                e.proto = nla_get_u8(tb[IPSET_ATTR_PROTO]);
@@ -497,10 +494,7 @@ hash_netportnet6_uadt(struct ip_set *set, struct nlattr *tb[],
        ip6_netmask(&e.ip[0], e.cidr[0]);
        ip6_netmask(&e.ip[1], e.cidr[1]);
 
-       if (tb[IPSET_ATTR_PORT])
-               e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
-       else
-               return -IPSET_ERR_PROTOCOL;
+       e.port = nla_get_be16(tb[IPSET_ATTR_PORT]);
 
        if (tb[IPSET_ATTR_PROTO]) {
                e.proto = nla_get_u8(tb[IPSET_ATTR_PROTO]);