aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2013-10-18 05:41:57 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2013-10-22 04:14:01 -0400
commit1a869205c75cb222263fa04f200485ffbe9eaadf (patch)
tree26b39361ecd210afbe95cebd3d43baccba58cb4c
parent93302880d8a3e5dc6b7da3f9825beb839152c940 (diff)
netfilter: ipset: The unnamed union initialization may lead to compilation error
The unnamed union should be possible to be initialized directly, but unfortunately it's not so: /usr/src/ipset/kernel/net/netfilter/ipset/ip_set_hash_netnet.c: In function ?hash_netnet4_kadt?: /usr/src/ipset/kernel/net/netfilter/ipset/ip_set_hash_netnet.c:141: error: unknown field ?cidr? specified in initializer Reported-by: Husnu Demir <hdemir@metu.edu.tr> Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--net/netfilter/ipset/ip_set_hash_netnet.c22
-rw-r--r--net/netfilter/ipset/ip_set_hash_netportnet.c22
2 files changed, 20 insertions, 24 deletions
diff --git a/net/netfilter/ipset/ip_set_hash_netnet.c b/net/netfilter/ipset/ip_set_hash_netnet.c
index 426032706ca9..2bc2dec20b00 100644
--- a/net/netfilter/ipset/ip_set_hash_netnet.c
+++ b/net/netfilter/ipset/ip_set_hash_netnet.c
@@ -137,12 +137,11 @@ hash_netnet4_kadt(struct ip_set *set, const struct sk_buff *skb,
137{ 137{
138 const struct hash_netnet *h = set->data; 138 const struct hash_netnet *h = set->data;
139 ipset_adtfn adtfn = set->variant->adt[adt]; 139 ipset_adtfn adtfn = set->variant->adt[adt];
140 struct hash_netnet4_elem e = { 140 struct hash_netnet4_elem e = { };
141 .cidr[0] = h->nets[0].cidr[0] ? h->nets[0].cidr[0] : HOST_MASK,
142 .cidr[1] = h->nets[0].cidr[1] ? h->nets[0].cidr[1] : HOST_MASK,
143 };
144 struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set); 141 struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set);
145 142
143 e.cidr[0] = IP_SET_INIT_CIDR(h->nets[0].cidr[0], HOST_MASK);
144 e.cidr[1] = IP_SET_INIT_CIDR(h->nets[0].cidr[1], HOST_MASK);
146 if (adt == IPSET_TEST) 145 if (adt == IPSET_TEST)
147 e.ccmp = (HOST_MASK << (sizeof(e.cidr[0]) * 8)) | HOST_MASK; 146 e.ccmp = (HOST_MASK << (sizeof(e.cidr[0]) * 8)) | HOST_MASK;
148 147
@@ -160,14 +159,14 @@ hash_netnet4_uadt(struct ip_set *set, struct nlattr *tb[],
160{ 159{
161 const struct hash_netnet *h = set->data; 160 const struct hash_netnet *h = set->data;
162 ipset_adtfn adtfn = set->variant->adt[adt]; 161 ipset_adtfn adtfn = set->variant->adt[adt];
163 struct hash_netnet4_elem e = { .cidr[0] = HOST_MASK, 162 struct hash_netnet4_elem e = { };
164 .cidr[1] = HOST_MASK };
165 struct ip_set_ext ext = IP_SET_INIT_UEXT(set); 163 struct ip_set_ext ext = IP_SET_INIT_UEXT(set);
166 u32 ip = 0, ip_to = 0, last; 164 u32 ip = 0, ip_to = 0, last;
167 u32 ip2 = 0, ip2_from = 0, ip2_to = 0, last2; 165 u32 ip2 = 0, ip2_from = 0, ip2_to = 0, last2;
168 u8 cidr, cidr2; 166 u8 cidr, cidr2;
169 int ret; 167 int ret;
170 168
169 e.cidr[0] = e.cidr[1] = HOST_MASK;
171 if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] || 170 if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] ||
172 !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT) || 171 !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT) ||
173 !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS) || 172 !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS) ||
@@ -364,12 +363,11 @@ hash_netnet6_kadt(struct ip_set *set, const struct sk_buff *skb,
364{ 363{
365 const struct hash_netnet *h = set->data; 364 const struct hash_netnet *h = set->data;
366 ipset_adtfn adtfn = set->variant->adt[adt]; 365 ipset_adtfn adtfn = set->variant->adt[adt];
367 struct hash_netnet6_elem e = { 366 struct hash_netnet6_elem e = { };
368 .cidr[0] = h->nets[0].cidr[0] ? h->nets[0].cidr[0] : HOST_MASK,
369 .cidr[1] = h->nets[0].cidr[1] ? h->nets[0].cidr[1] : HOST_MASK
370 };
371 struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set); 367 struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set);
372 368
369 e.cidr[0] = IP_SET_INIT_CIDR(h->nets[0].cidr[0], HOST_MASK);
370 e.cidr[1] = IP_SET_INIT_CIDR(h->nets[0].cidr[1], HOST_MASK);
373 if (adt == IPSET_TEST) 371 if (adt == IPSET_TEST)
374 e.ccmp = (HOST_MASK << (sizeof(u8)*8)) | HOST_MASK; 372 e.ccmp = (HOST_MASK << (sizeof(u8)*8)) | HOST_MASK;
375 373
@@ -386,11 +384,11 @@ hash_netnet6_uadt(struct ip_set *set, struct nlattr *tb[],
386 enum ipset_adt adt, u32 *lineno, u32 flags, bool retried) 384 enum ipset_adt adt, u32 *lineno, u32 flags, bool retried)
387{ 385{
388 ipset_adtfn adtfn = set->variant->adt[adt]; 386 ipset_adtfn adtfn = set->variant->adt[adt];
389 struct hash_netnet6_elem e = { .cidr[0] = HOST_MASK, 387 struct hash_netnet6_elem e = { };
390 .cidr[1] = HOST_MASK };
391 struct ip_set_ext ext = IP_SET_INIT_UEXT(set); 388 struct ip_set_ext ext = IP_SET_INIT_UEXT(set);
392 int ret; 389 int ret;
393 390
391 e.cidr[0] = e.cidr[1] = HOST_MASK;
394 if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] || 392 if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] ||
395 !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT) || 393 !ip_set_optattr_netorder(tb, IPSET_ATTR_TIMEOUT) ||
396 !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS) || 394 !ip_set_optattr_netorder(tb, IPSET_ATTR_CADT_FLAGS) ||
diff --git a/net/netfilter/ipset/ip_set_hash_netportnet.c b/net/netfilter/ipset/ip_set_hash_netportnet.c
index 363fab933d48..703d1192a6a2 100644
--- a/net/netfilter/ipset/ip_set_hash_netportnet.c
+++ b/net/netfilter/ipset/ip_set_hash_netportnet.c
@@ -147,12 +147,11 @@ hash_netportnet4_kadt(struct ip_set *set, const struct sk_buff *skb,
147{ 147{
148 const struct hash_netportnet *h = set->data; 148 const struct hash_netportnet *h = set->data;
149 ipset_adtfn adtfn = set->variant->adt[adt]; 149 ipset_adtfn adtfn = set->variant->adt[adt];
150 struct hash_netportnet4_elem e = { 150 struct hash_netportnet4_elem e = { };
151 .cidr[0] = IP_SET_INIT_CIDR(h->nets[0].cidr[0], HOST_MASK),
152 .cidr[1] = IP_SET_INIT_CIDR(h->nets[0].cidr[1], HOST_MASK),
153 };
154 struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set); 151 struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set);
155 152
153 e.cidr[0] = IP_SET_INIT_CIDR(h->nets[0].cidr[0], HOST_MASK);
154 e.cidr[1] = IP_SET_INIT_CIDR(h->nets[0].cidr[1], HOST_MASK);
156 if (adt == IPSET_TEST) 155 if (adt == IPSET_TEST)
157 e.ccmp = (HOST_MASK << (sizeof(e.cidr[0]) * 8)) | HOST_MASK; 156 e.ccmp = (HOST_MASK << (sizeof(e.cidr[0]) * 8)) | HOST_MASK;
158 157
@@ -174,8 +173,7 @@ hash_netportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
174{ 173{
175 const struct hash_netportnet *h = set->data; 174 const struct hash_netportnet *h = set->data;
176 ipset_adtfn adtfn = set->variant->adt[adt]; 175 ipset_adtfn adtfn = set->variant->adt[adt];
177 struct hash_netportnet4_elem e = { .cidr[0] = HOST_MASK, 176 struct hash_netportnet4_elem e = { };
178 .cidr[1] = HOST_MASK };
179 struct ip_set_ext ext = IP_SET_INIT_UEXT(set); 177 struct ip_set_ext ext = IP_SET_INIT_UEXT(set);
180 u32 ip = 0, ip_to = 0, ip_last, p = 0, port, port_to; 178 u32 ip = 0, ip_to = 0, ip_last, p = 0, port, port_to;
181 u32 ip2_from = 0, ip2_to = 0, ip2_last, ip2; 179 u32 ip2_from = 0, ip2_to = 0, ip2_last, ip2;
@@ -183,6 +181,7 @@ hash_netportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
183 u8 cidr, cidr2; 181 u8 cidr, cidr2;
184 int ret; 182 int ret;
185 183
184 e.cidr[0] = e.cidr[1] = HOST_MASK;
186 if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] || 185 if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] ||
187 !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) || 186 !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) ||
188 !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) || 187 !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) ||
@@ -419,12 +418,11 @@ hash_netportnet6_kadt(struct ip_set *set, const struct sk_buff *skb,
419{ 418{
420 const struct hash_netportnet *h = set->data; 419 const struct hash_netportnet *h = set->data;
421 ipset_adtfn adtfn = set->variant->adt[adt]; 420 ipset_adtfn adtfn = set->variant->adt[adt];
422 struct hash_netportnet6_elem e = { 421 struct hash_netportnet6_elem e = { };
423 .cidr[0] = IP_SET_INIT_CIDR(h->nets[0].cidr[0], HOST_MASK),
424 .cidr[1] = IP_SET_INIT_CIDR(h->nets[0].cidr[1], HOST_MASK),
425 };
426 struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set); 422 struct ip_set_ext ext = IP_SET_INIT_KEXT(skb, opt, set);
427 423
424 e.cidr[0] = IP_SET_INIT_CIDR(h->nets[0].cidr[0], HOST_MASK);
425 e.cidr[1] = IP_SET_INIT_CIDR(h->nets[0].cidr[1], HOST_MASK);
428 if (adt == IPSET_TEST) 426 if (adt == IPSET_TEST)
429 e.ccmp = (HOST_MASK << (sizeof(u8) * 8)) | HOST_MASK; 427 e.ccmp = (HOST_MASK << (sizeof(u8) * 8)) | HOST_MASK;
430 428
@@ -446,13 +444,13 @@ hash_netportnet6_uadt(struct ip_set *set, struct nlattr *tb[],
446{ 444{
447 const struct hash_netportnet *h = set->data; 445 const struct hash_netportnet *h = set->data;
448 ipset_adtfn adtfn = set->variant->adt[adt]; 446 ipset_adtfn adtfn = set->variant->adt[adt];
449 struct hash_netportnet6_elem e = { .cidr[0] = HOST_MASK, 447 struct hash_netportnet6_elem e = { };
450 .cidr[1] = HOST_MASK };
451 struct ip_set_ext ext = IP_SET_INIT_UEXT(set); 448 struct ip_set_ext ext = IP_SET_INIT_UEXT(set);
452 u32 port, port_to; 449 u32 port, port_to;
453 bool with_ports = false; 450 bool with_ports = false;
454 int ret; 451 int ret;
455 452
453 e.cidr[0] = e.cidr[1] = HOST_MASK;
456 if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] || 454 if (unlikely(!tb[IPSET_ATTR_IP] || !tb[IPSET_ATTR_IP2] ||
457 !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) || 455 !ip_set_attr_netorder(tb, IPSET_ATTR_PORT) ||
458 !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) || 456 !ip_set_optattr_netorder(tb, IPSET_ATTR_PORT_TO) ||