aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/netfilter/nfnetlink.h2
-rw-r--r--net/ipv4/netfilter/ip_conntrack_netlink.c45
-rw-r--r--net/ipv4/netfilter/ip_conntrack_proto_tcp.c6
-rw-r--r--net/netfilter/nfnetlink.c4
4 files changed, 11 insertions, 46 deletions
diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
index f08e870100f4..72975fa8795d 100644
--- a/include/linux/netfilter/nfnetlink.h
+++ b/include/linux/netfilter/nfnetlink.h
@@ -146,7 +146,7 @@ extern void nfnl_unlock(void);
146extern int nfnetlink_subsys_register(struct nfnetlink_subsystem *n); 146extern int nfnetlink_subsys_register(struct nfnetlink_subsystem *n);
147extern int nfnetlink_subsys_unregister(struct nfnetlink_subsystem *n); 147extern int nfnetlink_subsys_unregister(struct nfnetlink_subsystem *n);
148 148
149extern int nfattr_parse(struct nfattr *tb[], int maxattr, 149extern void nfattr_parse(struct nfattr *tb[], int maxattr,
150 struct nfattr *nfa, int len); 150 struct nfattr *nfa, int len);
151 151
152#define nfattr_parse_nested(tb, max, nfa) \ 152#define nfattr_parse_nested(tb, max, nfa) \
diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c
index 02f303cf201e..838262e17376 100644
--- a/net/ipv4/netfilter/ip_conntrack_netlink.c
+++ b/net/ipv4/netfilter/ip_conntrack_netlink.c
@@ -482,9 +482,7 @@ ctnetlink_parse_tuple_ip(struct nfattr *attr, struct ip_conntrack_tuple *tuple)
482 482
483 DEBUGP("entered %s\n", __FUNCTION__); 483 DEBUGP("entered %s\n", __FUNCTION__);
484 484
485 485 nfattr_parse_nested(tb, CTA_IP_MAX, attr);
486 if (nfattr_parse_nested(tb, CTA_IP_MAX, attr) < 0)
487 goto nfattr_failure;
488 486
489 if (nfattr_bad_size(tb, CTA_IP_MAX, cta_min_ip)) 487 if (nfattr_bad_size(tb, CTA_IP_MAX, cta_min_ip))
490 return -EINVAL; 488 return -EINVAL;
@@ -500,9 +498,6 @@ ctnetlink_parse_tuple_ip(struct nfattr *attr, struct ip_conntrack_tuple *tuple)
500 DEBUGP("leaving\n"); 498 DEBUGP("leaving\n");
501 499
502 return 0; 500 return 0;
503
504nfattr_failure:
505 return -1;
506} 501}
507 502
508static const int cta_min_proto[CTA_PROTO_MAX] = { 503static const int cta_min_proto[CTA_PROTO_MAX] = {
@@ -524,8 +519,7 @@ ctnetlink_parse_tuple_proto(struct nfattr *attr,
524 519
525 DEBUGP("entered %s\n", __FUNCTION__); 520 DEBUGP("entered %s\n", __FUNCTION__);
526 521
527 if (nfattr_parse_nested(tb, CTA_PROTO_MAX, attr) < 0) 522 nfattr_parse_nested(tb, CTA_PROTO_MAX, attr);
528 goto nfattr_failure;
529 523
530 if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto)) 524 if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto))
531 return -EINVAL; 525 return -EINVAL;
@@ -542,9 +536,6 @@ ctnetlink_parse_tuple_proto(struct nfattr *attr,
542 } 536 }
543 537
544 return ret; 538 return ret;
545
546nfattr_failure:
547 return -1;
548} 539}
549 540
550static inline int 541static inline int
@@ -558,8 +549,7 @@ ctnetlink_parse_tuple(struct nfattr *cda[], struct ip_conntrack_tuple *tuple,
558 549
559 memset(tuple, 0, sizeof(*tuple)); 550 memset(tuple, 0, sizeof(*tuple));
560 551
561 if (nfattr_parse_nested(tb, CTA_TUPLE_MAX, cda[type-1]) < 0) 552 nfattr_parse_nested(tb, CTA_TUPLE_MAX, cda[type-1]);
562 goto nfattr_failure;
563 553
564 if (!tb[CTA_TUPLE_IP-1]) 554 if (!tb[CTA_TUPLE_IP-1])
565 return -EINVAL; 555 return -EINVAL;
@@ -586,9 +576,6 @@ ctnetlink_parse_tuple(struct nfattr *cda[], struct ip_conntrack_tuple *tuple,
586 DEBUGP("leaving\n"); 576 DEBUGP("leaving\n");
587 577
588 return 0; 578 return 0;
589
590nfattr_failure:
591 return -1;
592} 579}
593 580
594#ifdef CONFIG_IP_NF_NAT_NEEDED 581#ifdef CONFIG_IP_NF_NAT_NEEDED
@@ -606,11 +593,10 @@ static int ctnetlink_parse_nat_proto(struct nfattr *attr,
606 593
607 DEBUGP("entered %s\n", __FUNCTION__); 594 DEBUGP("entered %s\n", __FUNCTION__);
608 595
609 if (nfattr_parse_nested(tb, CTA_PROTONAT_MAX, attr) < 0) 596 nfattr_parse_nested(tb, CTA_PROTONAT_MAX, attr);
610 goto nfattr_failure;
611 597
612 if (nfattr_bad_size(tb, CTA_PROTONAT_MAX, cta_min_protonat)) 598 if (nfattr_bad_size(tb, CTA_PROTONAT_MAX, cta_min_protonat))
613 goto nfattr_failure; 599 return -1;
614 600
615 npt = ip_nat_proto_find_get(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum); 601 npt = ip_nat_proto_find_get(ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum);
616 if (!npt) 602 if (!npt)
@@ -629,9 +615,6 @@ static int ctnetlink_parse_nat_proto(struct nfattr *attr,
629 615
630 DEBUGP("leaving\n"); 616 DEBUGP("leaving\n");
631 return 0; 617 return 0;
632
633nfattr_failure:
634 return -1;
635} 618}
636 619
637static inline int 620static inline int
@@ -645,8 +628,7 @@ ctnetlink_parse_nat(struct nfattr *cda[],
645 628
646 memset(range, 0, sizeof(*range)); 629 memset(range, 0, sizeof(*range));
647 630
648 if (nfattr_parse_nested(tb, CTA_NAT_MAX, cda[CTA_NAT-1]) < 0) 631 nfattr_parse_nested(tb, CTA_NAT_MAX, cda[CTA_NAT-1]);
649 goto nfattr_failure;
650 632
651 if (tb[CTA_NAT_MINIP-1]) 633 if (tb[CTA_NAT_MINIP-1])
652 range->min_ip = *(u_int32_t *)NFA_DATA(tb[CTA_NAT_MINIP-1]); 634 range->min_ip = *(u_int32_t *)NFA_DATA(tb[CTA_NAT_MINIP-1]);
@@ -668,9 +650,6 @@ ctnetlink_parse_nat(struct nfattr *cda[],
668 650
669 DEBUGP("leaving\n"); 651 DEBUGP("leaving\n");
670 return 0; 652 return 0;
671
672nfattr_failure:
673 return -1;
674} 653}
675#endif 654#endif
676 655
@@ -681,8 +660,7 @@ ctnetlink_parse_help(struct nfattr *attr, char **helper_name)
681 660
682 DEBUGP("entered %s\n", __FUNCTION__); 661 DEBUGP("entered %s\n", __FUNCTION__);
683 662
684 if (nfattr_parse_nested(tb, CTA_HELP_MAX, attr) < 0) 663 nfattr_parse_nested(tb, CTA_HELP_MAX, attr);
685 goto nfattr_failure;
686 664
687 if (!tb[CTA_HELP_NAME-1]) 665 if (!tb[CTA_HELP_NAME-1])
688 return -EINVAL; 666 return -EINVAL;
@@ -690,9 +668,6 @@ ctnetlink_parse_help(struct nfattr *attr, char **helper_name)
690 *helper_name = NFA_DATA(tb[CTA_HELP_NAME-1]); 668 *helper_name = NFA_DATA(tb[CTA_HELP_NAME-1]);
691 669
692 return 0; 670 return 0;
693
694nfattr_failure:
695 return -1;
696} 671}
697 672
698static int 673static int
@@ -960,8 +935,7 @@ ctnetlink_change_protoinfo(struct ip_conntrack *ct, struct nfattr *cda[])
960 u_int16_t npt = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum; 935 u_int16_t npt = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum;
961 int err = 0; 936 int err = 0;
962 937
963 if (nfattr_parse_nested(tb, CTA_PROTOINFO_MAX, attr) < 0) 938 nfattr_parse_nested(tb, CTA_PROTOINFO_MAX, attr);
964 goto nfattr_failure;
965 939
966 proto = ip_conntrack_proto_find_get(npt); 940 proto = ip_conntrack_proto_find_get(npt);
967 if (!proto) 941 if (!proto)
@@ -972,9 +946,6 @@ ctnetlink_change_protoinfo(struct ip_conntrack *ct, struct nfattr *cda[])
972 ip_conntrack_proto_put(proto); 946 ip_conntrack_proto_put(proto);
973 947
974 return err; 948 return err;
975
976nfattr_failure:
977 return -ENOMEM;
978} 949}
979 950
980static int 951static int
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
index d6701cafbcc2..6ea4b22ff28d 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
@@ -362,8 +362,7 @@ static int nfattr_to_tcp(struct nfattr *cda[], struct ip_conntrack *ct)
362 struct nfattr *attr = cda[CTA_PROTOINFO_TCP-1]; 362 struct nfattr *attr = cda[CTA_PROTOINFO_TCP-1];
363 struct nfattr *tb[CTA_PROTOINFO_TCP_MAX]; 363 struct nfattr *tb[CTA_PROTOINFO_TCP_MAX];
364 364
365 if (nfattr_parse_nested(tb, CTA_PROTOINFO_TCP_MAX, attr) < 0) 365 nfattr_parse_nested(tb, CTA_PROTOINFO_TCP_MAX, attr);
366 goto nfattr_failure;
367 366
368 if (!tb[CTA_PROTOINFO_TCP_STATE-1]) 367 if (!tb[CTA_PROTOINFO_TCP_STATE-1])
369 return -EINVAL; 368 return -EINVAL;
@@ -374,9 +373,6 @@ static int nfattr_to_tcp(struct nfattr *cda[], struct ip_conntrack *ct)
374 write_unlock_bh(&tcp_lock); 373 write_unlock_bh(&tcp_lock);
375 374
376 return 0; 375 return 0;
377
378nfattr_failure:
379 return -1;
380} 376}
381#endif 377#endif
382 378
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 4bc27a6334c1..f8bd7c7e7921 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -128,7 +128,7 @@ void __nfa_fill(struct sk_buff *skb, int attrtype, int attrlen,
128 memset(NFA_DATA(nfa) + attrlen, 0, NFA_ALIGN(size) - size); 128 memset(NFA_DATA(nfa) + attrlen, 0, NFA_ALIGN(size) - size);
129} 129}
130 130
131int nfattr_parse(struct nfattr *tb[], int maxattr, struct nfattr *nfa, int len) 131void nfattr_parse(struct nfattr *tb[], int maxattr, struct nfattr *nfa, int len)
132{ 132{
133 memset(tb, 0, sizeof(struct nfattr *) * maxattr); 133 memset(tb, 0, sizeof(struct nfattr *) * maxattr);
134 134
@@ -138,8 +138,6 @@ int nfattr_parse(struct nfattr *tb[], int maxattr, struct nfattr *nfa, int len)
138 tb[flavor-1] = nfa; 138 tb[flavor-1] = nfa;
139 nfa = NFA_NEXT(nfa, len); 139 nfa = NFA_NEXT(nfa, len);
140 } 140 }
141
142 return 0;
143} 141}
144 142
145/** 143/**