]> granicus.if.org Git - ipset/commitdiff
netfilter: ipset: Make sure we always return line number on batch
authorSergey Popovich <popovich_sergei@mail.ua>
Mon, 17 Nov 2014 16:03:00 +0000 (18:03 +0200)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Fri, 20 Mar 2015 18:09:56 +0000 (19:09 +0100)
Even if we return with generic IPSET_ERR_PROTOCOL it is good idea
to return line number if we called in batch mode.

Moreover we are not always exiting with IPSET_ERR_PROTOCOL. For
example hash:ip,port,net may return IPSET_ERR_HASH_RANGE_UNSUPPORTED
or IPSET_ERR_INVALID_CIDR.

Signed-off-by: Sergey Popovich <popovich_sergei@mail.ua>
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
15 files changed:
kernel/net/netfilter/ipset/ip_set_bitmap_ip.c
kernel/net/netfilter/ipset/ip_set_bitmap_ipmac.c
kernel/net/netfilter/ipset/ip_set_bitmap_port.c
kernel/net/netfilter/ipset/ip_set_hash_ip.c
kernel/net/netfilter/ipset/ip_set_hash_ipmark.c
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_mac.c
kernel/net/netfilter/ipset/ip_set_hash_net.c
kernel/net/netfilter/ipset/ip_set_hash_netiface.c
kernel/net/netfilter/ipset/ip_set_hash_netnet.c
kernel/net/netfilter/ipset/ip_set_hash_netport.c
kernel/net/netfilter/ipset/ip_set_hash_netportnet.c
kernel/net/netfilter/ipset/ip_set_list_set.c

index a98cdfa13bca174fe43acb736c114f4905490c2f..d84d18438357f91df3d44da48f7696f472813a40 100644 (file)
@@ -138,12 +138,12 @@ bitmap_ip_uadt(struct ip_set *set, struct nlattr *tb[],
        struct ip_set_ext ext = IP_SET_INIT_UEXT(set);
        int ret = 0;
 
-       if (unlikely(!tb[IPSET_ATTR_IP]))
-               return -IPSET_ERR_PROTOCOL;
-
        if (tb[IPSET_ATTR_LINENO])
                *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
 
+       if (unlikely(!tb[IPSET_ATTR_IP]))
+               return -IPSET_ERR_PROTOCOL;
+
        ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP], &ip);
        if (ret)
                return ret;
index dbf067dc4309cb2818a63d0ec0c4bf6c55168ccb..55a7ebed4c0eb41ae4efdbcbacce2b6927799267 100644 (file)
@@ -240,12 +240,12 @@ bitmap_ipmac_uadt(struct ip_set *set, struct nlattr *tb[],
        u32 ip = 0;
        int ret = 0;
 
-       if (unlikely(!tb[IPSET_ATTR_IP]))
-               return -IPSET_ERR_PROTOCOL;
-
        if (tb[IPSET_ATTR_LINENO])
                *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
 
+       if (unlikely(!tb[IPSET_ATTR_IP]))
+               return -IPSET_ERR_PROTOCOL;
+
        ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP], &ip);
        if (ret)
                return ret;
index 366865f4b0bd581584ba3427e8994d72b6013aad..f8f8aff2c617dc0c259e39a2a13938c08884075f 100644 (file)
@@ -136,13 +136,13 @@ bitmap_port_uadt(struct ip_set *set, struct nlattr *tb[],
        u16 port_to;
        int ret = 0;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        if (unlikely(!ip_set_attr_netorder(tb, IPSET_ATTR_PORT) ||
                     !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO)))
                return -IPSET_ERR_PROTOCOL;
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        port = ip_set_get_h16(tb[IPSET_ATTR_PORT]);
        if (port < map->first_port || port > map->last_port)
                return -IPSET_ERR_BITMAP_RANGE;
index 1ad0178643adcbe91763f4e17b24872e4821c20a..effa9467e58a969a652f318b4506b1a2a4b81752 100644 (file)
@@ -108,12 +108,12 @@ hash_ip4_uadt(struct ip_set *set, struct nlattr *tb[],
        u32 ip = 0, ip_to = 0, hosts;
        int ret = 0;
 
-       if (unlikely(!tb[IPSET_ATTR_IP]))
-               return -IPSET_ERR_PROTOCOL;
-
        if (tb[IPSET_ATTR_LINENO])
                *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
 
+       if (unlikely(!tb[IPSET_ATTR_IP]))
+               return -IPSET_ERR_PROTOCOL;
+
        ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP], &ip);
        if (ret)
                return ret;
@@ -241,6 +241,9 @@ hash_ip6_uadt(struct ip_set *set, struct nlattr *tb[],
        struct ip_set_ext ext = IP_SET_INIT_UEXT(set);
        int ret;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        if (unlikely(!tb[IPSET_ATTR_IP]))
                return -IPSET_ERR_PROTOCOL;
        if (unlikely(tb[IPSET_ATTR_IP_TO]))
@@ -251,9 +254,6 @@ hash_ip6_uadt(struct ip_set *set, struct nlattr *tb[],
                        return -IPSET_ERR_INVALID_CIDR;
        }
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP], &e.ip);
        if (ret)
                return ret;
index 081b1f87b89c2c751403efaae130b3169f5c9bf2..b4dacb766c467d2429b510bde458627b237b8065 100644 (file)
@@ -109,13 +109,13 @@ hash_ipmark4_uadt(struct ip_set *set, struct nlattr *tb[],
        u32 ip, ip_to = 0;
        int ret;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        if (unlikely(!tb[IPSET_ATTR_IP] ||
                     !ip_set_attr_netorder(tb, IPSET_ATTR_MARK)))
                return -IPSET_ERR_PROTOCOL;
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_ipaddr4(tb[IPSET_ATTR_IP], &e.ip);
        if (ret)
                return ret;
@@ -236,6 +236,9 @@ hash_ipmark6_uadt(struct ip_set *set, struct nlattr *tb[],
        struct ip_set_ext ext = IP_SET_INIT_UEXT(set);
        int ret;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        if (unlikely(!tb[IPSET_ATTR_IP] ||
                     !ip_set_attr_netorder(tb, IPSET_ATTR_MARK)))
                return -IPSET_ERR_PROTOCOL;
@@ -247,9 +250,6 @@ hash_ipmark6_uadt(struct ip_set *set, struct nlattr *tb[],
                        return -IPSET_ERR_INVALID_CIDR;
        }
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP], &e.ip);
        if (ret)
                return ret;
index 55160089f6152696ee16639f7937bcce6e193b01..941f90158776ce3ca8fd3d86cd2ac8883e07b988 100644 (file)
@@ -117,14 +117,14 @@ hash_ipport4_uadt(struct ip_set *set, struct nlattr *tb[],
        bool with_ports = false;
        int ret;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        if (unlikely(!tb[IPSET_ATTR_IP] ||
                     !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) ||
                     !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO)))
                return -IPSET_ERR_PROTOCOL;
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_ipaddr4(tb[IPSET_ATTR_IP], &e.ip);
        if (ret)
                return ret;
@@ -277,6 +277,9 @@ hash_ipport6_uadt(struct ip_set *set, struct nlattr *tb[],
        bool with_ports = false;
        int ret;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        if (unlikely(!tb[IPSET_ATTR_IP] ||
                     !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) ||
                     !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO)))
@@ -289,9 +292,6 @@ hash_ipport6_uadt(struct ip_set *set, struct nlattr *tb[],
                        return -IPSET_ERR_INVALID_CIDR;
        }
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP], &e.ip);
        if (ret)
                return ret;
index 7bc08a3dcc3eff134253bd4a62b4eb6f94bf2fd1..fc52934d8bd79f46322ca1051392fa48d9204794 100644 (file)
@@ -119,14 +119,14 @@ hash_ipportip4_uadt(struct ip_set *set, struct nlattr *tb[],
        bool with_ports = false;
        int ret;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] ||
                     !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) ||
                     !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO)))
                return -IPSET_ERR_PROTOCOL;
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_ipaddr4(tb[IPSET_ATTR_IP], &e.ip);
        if (ret)
                return ret;
@@ -285,6 +285,9 @@ hash_ipportip6_uadt(struct ip_set *set, struct nlattr *tb[],
        bool with_ports = false;
        int ret;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] ||
                     !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) ||
                     !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO)))
@@ -297,9 +300,6 @@ hash_ipportip6_uadt(struct ip_set *set, struct nlattr *tb[],
                        return -IPSET_ERR_INVALID_CIDR;
        }
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP], &e.ip);
        if (ret)
                return ret;
index 0b15bd6a7503d13d5c1dc661e8c896bd3d59abbe..b6223e3b30411365928e9e816d86ccf6b3a44219 100644 (file)
@@ -173,15 +173,15 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
        u8 cidr;
        int ret;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] ||
                     !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) ||
                     !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) ||
                     !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS)))
                return -IPSET_ERR_PROTOCOL;
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP], &ip);
        if (ret)
                return ret;
@@ -423,6 +423,9 @@ hash_ipportnet6_uadt(struct ip_set *set, struct nlattr *tb[],
        u8 cidr;
        int ret;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] ||
                     !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) ||
                     !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) ||
@@ -436,9 +439,6 @@ hash_ipportnet6_uadt(struct ip_set *set, struct nlattr *tb[],
                        return -IPSET_ERR_INVALID_CIDR;
        }
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP], &e.ip);
        if (ret)
                return ret;
index 2c43e50f6e41fadadbdd80e3ad4446aebacb2617..aa20c2092a04cc5ba7da22e5aa2e81732edd0ee7 100644 (file)
@@ -102,12 +102,12 @@ hash_mac4_uadt(struct ip_set *set, struct nlattr *tb[],
        struct ip_set_ext ext = IP_SET_INIT_UEXT(set);
        int ret;
 
-       if (unlikely(!tb[IPSET_ATTR_ETHER]))
-               return -IPSET_ERR_PROTOCOL;
-
        if (tb[IPSET_ATTR_LINENO])
                *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
 
+       if (unlikely(!tb[IPSET_ATTR_ETHER]))
+               return -IPSET_ERR_PROTOCOL;
+
        ret = ip_set_get_extensions(set, tb, &ext);
        if (ret)
                return ret;
index 9d6bcad949bfc3327e72c489b178b07cb44b05db..1f148f515d36fa0912b09fdcf07aa41274c18798 100644 (file)
@@ -146,13 +146,13 @@ hash_net4_uadt(struct ip_set *set, struct nlattr *tb[],
        u32 ip = 0, ip_to = 0, last;
        int ret;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        if (unlikely(!tb[IPSET_ATTR_IP] ||
                     !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS)))
                return -IPSET_ERR_PROTOCOL;
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP], &ip);
        if (ret)
                return ret;
@@ -313,15 +313,15 @@ hash_net6_uadt(struct ip_set *set, struct nlattr *tb[],
        struct ip_set_ext ext = IP_SET_INIT_UEXT(set);
        int ret;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        if (unlikely(!tb[IPSET_ATTR_IP] ||
                     !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS)))
                return -IPSET_ERR_PROTOCOL;
        if (unlikely(tb[IPSET_ATTR_IP_TO]))
                return -IPSET_ERR_HASH_RANGE_UNSUPPORTED;
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP], &e.ip);
        if (ret)
                return ret;
index 8accce0cbc429ad8a17205ba8027545f65f347a0..cb8e688cd036d485af46110de3ab214b9c6df2c3 100644 (file)
@@ -189,14 +189,14 @@ hash_netiface4_uadt(struct ip_set *set, struct nlattr *tb[],
        u32 ip = 0, ip_to = 0, last;
        int ret;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        if (unlikely(!tb[IPSET_ATTR_IP] ||
                     !tb[IPSET_ATTR_IFACE] ||
                     !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS)))
                return -IPSET_ERR_PROTOCOL;
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP], &ip);
        if (ret)
                return ret;
@@ -399,6 +399,9 @@ hash_netiface6_uadt(struct ip_set *set, struct nlattr *tb[],
        struct ip_set_ext ext = IP_SET_INIT_UEXT(set);
        int ret;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        if (unlikely(!tb[IPSET_ATTR_IP] ||
                     !tb[IPSET_ATTR_IFACE] ||
                     !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS)))
@@ -406,9 +409,6 @@ hash_netiface6_uadt(struct ip_set *set, struct nlattr *tb[],
        if (unlikely(tb[IPSET_ATTR_IP_TO]))
                return -IPSET_ERR_HASH_RANGE_UNSUPPORTED;
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP], &e.ip);
        if (ret)
                return ret;
index bb9c14520f1f0036f384f2508025ba791a582c2c..60faa3a763b5700108db353d7fb03531e3cf11af 100644 (file)
@@ -167,14 +167,14 @@ hash_netnet4_uadt(struct ip_set *set, struct nlattr *tb[],
        u8 cidr, cidr2;
        int ret;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        e.cidr[0] = e.cidr[1] = HOST_MASK;
        if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] ||
                     !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS)))
                return -IPSET_ERR_PROTOCOL;
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP], &ip);
        if (ret)
                return ret;
@@ -395,6 +395,9 @@ hash_netnet6_uadt(struct ip_set *set, struct nlattr *tb[],
        struct ip_set_ext ext = IP_SET_INIT_UEXT(set);
        int ret;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        e.cidr[0] = e.cidr[1] = HOST_MASK;
        if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] ||
                     !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS)))
@@ -402,9 +405,6 @@ hash_netnet6_uadt(struct ip_set *set, struct nlattr *tb[],
        if (unlikely(tb[IPSET_ATTR_IP_TO] || tb[IPSET_ATTR_IP2_TO]))
                return -IPSET_ERR_HASH_RANGE_UNSUPPORTED;
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP], &e.ip[0]);
        if (ret)
                return ret;
index 0196e40c76a89e7bc453b42490da34888c0fadaf..464122d557af1c10b6aaeb1ca097d6eb49841345 100644 (file)
@@ -166,15 +166,15 @@ hash_netport4_uadt(struct ip_set *set, struct nlattr *tb[],
        u8 cidr;
        int ret;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        if (unlikely(!tb[IPSET_ATTR_IP] ||
                     !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) ||
                     !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) ||
                     !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS)))
                return -IPSET_ERR_PROTOCOL;
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP], &ip);
        if (ret)
                return ret;
@@ -381,6 +381,9 @@ hash_netport6_uadt(struct ip_set *set, struct nlattr *tb[],
        u8 cidr;
        int ret;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        if (unlikely(!tb[IPSET_ATTR_IP] ||
                     !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) ||
                     !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) ||
@@ -389,9 +392,6 @@ hash_netport6_uadt(struct ip_set *set, struct nlattr *tb[],
        if (unlikely(tb[IPSET_ATTR_IP_TO]))
                return -IPSET_ERR_HASH_RANGE_UNSUPPORTED;
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP], &e.ip);
        if (ret)
                return ret;
index 2b4c4e2703b1d7bb601027e128d152ac34d888e3..cf3442dd3bb9309d1402c2497bf974e562d28833 100644 (file)
@@ -183,6 +183,9 @@ hash_netportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
        u8 cidr, cidr2;
        int ret;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        e.cidr[0] = e.cidr[1] = HOST_MASK;
        if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] ||
                     !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) ||
@@ -190,9 +193,6 @@ hash_netportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
                     !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS)))
                return -IPSET_ERR_PROTOCOL;
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP], &ip);
        if (ret)
                return ret;
@@ -457,6 +457,9 @@ hash_netportnet6_uadt(struct ip_set *set, struct nlattr *tb[],
        bool with_ports = false;
        int ret;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        e.cidr[0] = e.cidr[1] = HOST_MASK;
        if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] ||
                     !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) ||
@@ -466,9 +469,6 @@ hash_netportnet6_uadt(struct ip_set *set, struct nlattr *tb[],
        if (unlikely(tb[IPSET_ATTR_IP_TO] || tb[IPSET_ATTR_IP2_TO]))
                return -IPSET_ERR_HASH_RANGE_UNSUPPORTED;
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_ipaddr6(tb[IPSET_ATTR_IP], &e.ip[0]);
        if (ret)
                return ret;
index f2689574fe75952a490e859e4bac431b9a6d6c65..3c9681e32ef13197d411ac508c336c0ce6f2ed5a 100644 (file)
@@ -358,13 +358,13 @@ list_set_uadt(struct ip_set *set, struct nlattr *tb[],
        struct ip_set *s;
        int ret = 0;
 
+       if (tb[IPSET_ATTR_LINENO])
+               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
+
        if (unlikely(!tb[IPSET_ATTR_NAME] ||
                     !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS)))
                return -IPSET_ERR_PROTOCOL;
 
-       if (tb[IPSET_ATTR_LINENO])
-               *lineno = nla_get_u32(tb[IPSET_ATTR_LINENO]);
-
        ret = ip_set_get_extensions(set, tb, &ext);
        if (ret)
                return ret;