aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2008-01-15 02:44:05 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:02:29 -0500
commit022748a9357c4c1a0113ec1ce5612f383b80156f (patch)
tree9c1d64082f93011732c496d356543faa4ca76e01 /net
parentf9ef8a23c37677929e95ad4026a2fa0d449c1d3e (diff)
[NETFILTER]: {ip,ip6}_tables: remove some inlines
This patch removes inlines except those which are used by packet matching code and thus are performance-critical. Before: $ size */*/*/ip*tables*.o text data bss dec hex filename 6402 500 16 6918 1b06 net/ipv4/netfilter/ip_tables.o 7130 500 16 7646 1dde net/ipv6/netfilter/ip6_tables.o After: $ size */*/*/ip*tables*.o text data bss dec hex filename 6307 500 16 6823 1aa7 net/ipv4/netfilter/ip_tables.o 7010 500 16 7526 1d66 net/ipv6/netfilter/ip6_tables.o Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/netfilter/ip_tables.c47
-rw-r--r--net/ipv6/netfilter/ip6_tables.c42
2 files changed, 50 insertions, 39 deletions
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index f5b66ec18b0d..982b7f986291 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -75,6 +75,7 @@ do { \
75 Hence the start of any table is given by get_table() below. */ 75 Hence the start of any table is given by get_table() below. */
76 76
77/* Returns whether matches rule or not. */ 77/* Returns whether matches rule or not. */
78/* Performance critical - called for every packet */
78static inline bool 79static inline bool
79ip_packet_match(const struct iphdr *ip, 80ip_packet_match(const struct iphdr *ip,
80 const char *indev, 81 const char *indev,
@@ -153,7 +154,7 @@ ip_packet_match(const struct iphdr *ip,
153 return true; 154 return true;
154} 155}
155 156
156static inline bool 157static bool
157ip_checkentry(const struct ipt_ip *ip) 158ip_checkentry(const struct ipt_ip *ip)
158{ 159{
159 if (ip->flags & ~IPT_F_MASK) { 160 if (ip->flags & ~IPT_F_MASK) {
@@ -183,8 +184,9 @@ ipt_error(struct sk_buff *skb,
183 return NF_DROP; 184 return NF_DROP;
184} 185}
185 186
186static inline 187/* Performance critical - called for every packet */
187bool do_match(struct ipt_entry_match *m, 188static inline bool
189do_match(struct ipt_entry_match *m,
188 const struct sk_buff *skb, 190 const struct sk_buff *skb,
189 const struct net_device *in, 191 const struct net_device *in,
190 const struct net_device *out, 192 const struct net_device *out,
@@ -199,6 +201,7 @@ bool do_match(struct ipt_entry_match *m,
199 return false; 201 return false;
200} 202}
201 203
204/* Performance critical */
202static inline struct ipt_entry * 205static inline struct ipt_entry *
203get_entry(void *base, unsigned int offset) 206get_entry(void *base, unsigned int offset)
204{ 207{
@@ -206,6 +209,7 @@ get_entry(void *base, unsigned int offset)
206} 209}
207 210
208/* All zeroes == unconditional rule. */ 211/* All zeroes == unconditional rule. */
212/* Mildly perf critical (only if packet tracing is on) */
209static inline int 213static inline int
210unconditional(const struct ipt_ip *ip) 214unconditional(const struct ipt_ip *ip)
211{ 215{
@@ -221,7 +225,7 @@ unconditional(const struct ipt_ip *ip)
221 225
222#if defined(CONFIG_NETFILTER_XT_TARGET_TRACE) || \ 226#if defined(CONFIG_NETFILTER_XT_TARGET_TRACE) || \
223 defined(CONFIG_NETFILTER_XT_TARGET_TRACE_MODULE) 227 defined(CONFIG_NETFILTER_XT_TARGET_TRACE_MODULE)
224static const char *hooknames[] = { 228static const char *const hooknames[] = {
225 [NF_INET_PRE_ROUTING] = "PREROUTING", 229 [NF_INET_PRE_ROUTING] = "PREROUTING",
226 [NF_INET_LOCAL_IN] = "INPUT", 230 [NF_INET_LOCAL_IN] = "INPUT",
227 [NF_INET_FORWARD] = "FORWARD", 231 [NF_INET_FORWARD] = "FORWARD",
@@ -235,7 +239,7 @@ enum nf_ip_trace_comments {
235 NF_IP_TRACE_COMMENT_POLICY, 239 NF_IP_TRACE_COMMENT_POLICY,
236}; 240};
237 241
238static const char *comments[] = { 242static const char *const comments[] = {
239 [NF_IP_TRACE_COMMENT_RULE] = "rule", 243 [NF_IP_TRACE_COMMENT_RULE] = "rule",
240 [NF_IP_TRACE_COMMENT_RETURN] = "return", 244 [NF_IP_TRACE_COMMENT_RETURN] = "return",
241 [NF_IP_TRACE_COMMENT_POLICY] = "policy", 245 [NF_IP_TRACE_COMMENT_POLICY] = "policy",
@@ -251,6 +255,7 @@ static struct nf_loginfo trace_loginfo = {
251 }, 255 },
252}; 256};
253 257
258/* Mildly perf critical (only if packet tracing is on) */
254static inline int 259static inline int
255get_chainname_rulenum(struct ipt_entry *s, struct ipt_entry *e, 260get_chainname_rulenum(struct ipt_entry *s, struct ipt_entry *e,
256 char *hookname, char **chainname, 261 char *hookname, char **chainname,
@@ -567,7 +572,7 @@ mark_source_chains(struct xt_table_info *newinfo,
567 return 1; 572 return 1;
568} 573}
569 574
570static inline int 575static int
571cleanup_match(struct ipt_entry_match *m, unsigned int *i) 576cleanup_match(struct ipt_entry_match *m, unsigned int *i)
572{ 577{
573 if (i && (*i)-- == 0) 578 if (i && (*i)-- == 0)
@@ -579,7 +584,7 @@ cleanup_match(struct ipt_entry_match *m, unsigned int *i)
579 return 0; 584 return 0;
580} 585}
581 586
582static inline int 587static int
583check_entry(struct ipt_entry *e, const char *name) 588check_entry(struct ipt_entry *e, const char *name)
584{ 589{
585 struct ipt_entry_target *t; 590 struct ipt_entry_target *t;
@@ -600,7 +605,8 @@ check_entry(struct ipt_entry *e, const char *name)
600 return 0; 605 return 0;
601} 606}
602 607
603static inline int check_match(struct ipt_entry_match *m, const char *name, 608static int
609check_match(struct ipt_entry_match *m, const char *name,
604 const struct ipt_ip *ip, 610 const struct ipt_ip *ip,
605 unsigned int hookmask, unsigned int *i) 611 unsigned int hookmask, unsigned int *i)
606{ 612{
@@ -623,7 +629,7 @@ static inline int check_match(struct ipt_entry_match *m, const char *name,
623 return ret; 629 return ret;
624} 630}
625 631
626static inline int 632static int
627find_check_match(struct ipt_entry_match *m, 633find_check_match(struct ipt_entry_match *m,
628 const char *name, 634 const char *name,
629 const struct ipt_ip *ip, 635 const struct ipt_ip *ip,
@@ -652,7 +658,7 @@ err:
652 return ret; 658 return ret;
653} 659}
654 660
655static inline int check_target(struct ipt_entry *e, const char *name) 661static int check_target(struct ipt_entry *e, const char *name)
656{ 662{
657 struct ipt_entry_target *t; 663 struct ipt_entry_target *t;
658 struct xt_target *target; 664 struct xt_target *target;
@@ -673,7 +679,7 @@ static inline int check_target(struct ipt_entry *e, const char *name)
673 return ret; 679 return ret;
674} 680}
675 681
676static inline int 682static int
677find_check_entry(struct ipt_entry *e, const char *name, unsigned int size, 683find_check_entry(struct ipt_entry *e, const char *name, unsigned int size,
678 unsigned int *i) 684 unsigned int *i)
679{ 685{
@@ -717,7 +723,7 @@ find_check_entry(struct ipt_entry *e, const char *name, unsigned int size,
717 return ret; 723 return ret;
718} 724}
719 725
720static inline int 726static int
721check_entry_size_and_hooks(struct ipt_entry *e, 727check_entry_size_and_hooks(struct ipt_entry *e,
722 struct xt_table_info *newinfo, 728 struct xt_table_info *newinfo,
723 unsigned char *base, 729 unsigned char *base,
@@ -760,7 +766,7 @@ check_entry_size_and_hooks(struct ipt_entry *e,
760 return 0; 766 return 0;
761} 767}
762 768
763static inline int 769static int
764cleanup_entry(struct ipt_entry *e, unsigned int *i) 770cleanup_entry(struct ipt_entry *e, unsigned int *i)
765{ 771{
766 struct ipt_entry_target *t; 772 struct ipt_entry_target *t;
@@ -916,7 +922,7 @@ get_counters(const struct xt_table_info *t,
916 } 922 }
917} 923}
918 924
919static inline struct xt_counters * alloc_counters(struct xt_table *table) 925static struct xt_counters * alloc_counters(struct xt_table *table)
920{ 926{
921 unsigned int countersize; 927 unsigned int countersize;
922 struct xt_counters *counters; 928 struct xt_counters *counters;
@@ -1304,7 +1310,7 @@ do_replace(void __user *user, unsigned int len)
1304 1310
1305/* We're lazy, and add to the first CPU; overflow works its fey magic 1311/* We're lazy, and add to the first CPU; overflow works its fey magic
1306 * and everything is OK. */ 1312 * and everything is OK. */
1307static inline int 1313static int
1308add_counter_to_entry(struct ipt_entry *e, 1314add_counter_to_entry(struct ipt_entry *e,
1309 const struct xt_counters addme[], 1315 const struct xt_counters addme[],
1310 unsigned int *i) 1316 unsigned int *i)
@@ -1465,7 +1471,7 @@ out:
1465 return ret; 1471 return ret;
1466} 1472}
1467 1473
1468static inline int 1474static int
1469compat_find_calc_match(struct ipt_entry_match *m, 1475compat_find_calc_match(struct ipt_entry_match *m,
1470 const char *name, 1476 const char *name,
1471 const struct ipt_ip *ip, 1477 const struct ipt_ip *ip,
@@ -1489,7 +1495,7 @@ compat_find_calc_match(struct ipt_entry_match *m,
1489 return 0; 1495 return 0;
1490} 1496}
1491 1497
1492static inline int 1498static int
1493compat_release_match(struct ipt_entry_match *m, unsigned int *i) 1499compat_release_match(struct ipt_entry_match *m, unsigned int *i)
1494{ 1500{
1495 if (i && (*i)-- == 0) 1501 if (i && (*i)-- == 0)
@@ -1499,7 +1505,7 @@ compat_release_match(struct ipt_entry_match *m, unsigned int *i)
1499 return 0; 1505 return 0;
1500} 1506}
1501 1507
1502static inline int 1508static int
1503compat_release_entry(struct compat_ipt_entry *e, unsigned int *i) 1509compat_release_entry(struct compat_ipt_entry *e, unsigned int *i)
1504{ 1510{
1505 struct ipt_entry_target *t; 1511 struct ipt_entry_target *t;
@@ -1514,7 +1520,7 @@ compat_release_entry(struct compat_ipt_entry *e, unsigned int *i)
1514 return 0; 1520 return 0;
1515} 1521}
1516 1522
1517static inline int 1523static int
1518check_compat_entry_size_and_hooks(struct compat_ipt_entry *e, 1524check_compat_entry_size_and_hooks(struct compat_ipt_entry *e,
1519 struct xt_table_info *newinfo, 1525 struct xt_table_info *newinfo,
1520 unsigned int *size, 1526 unsigned int *size,
@@ -1637,7 +1643,8 @@ compat_copy_entry_from_user(struct compat_ipt_entry *e, void **dstptr,
1637 return ret; 1643 return ret;
1638} 1644}
1639 1645
1640static inline int compat_check_entry(struct ipt_entry *e, const char *name, 1646static int
1647compat_check_entry(struct ipt_entry *e, const char *name,
1641 unsigned int *i) 1648 unsigned int *i)
1642{ 1649{
1643 int j, ret; 1650 int j, ret;
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 4ed16d254b98..dd7860fea61f 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -90,6 +90,7 @@ ip6t_ext_hdr(u8 nexthdr)
90} 90}
91 91
92/* Returns whether matches rule or not. */ 92/* Returns whether matches rule or not. */
93/* Performance critical - called for every packet */
93static inline bool 94static inline bool
94ip6_packet_match(const struct sk_buff *skb, 95ip6_packet_match(const struct sk_buff *skb,
95 const char *indev, 96 const char *indev,
@@ -182,7 +183,7 @@ ip6_packet_match(const struct sk_buff *skb,
182} 183}
183 184
184/* should be ip6 safe */ 185/* should be ip6 safe */
185static inline bool 186static bool
186ip6_checkentry(const struct ip6t_ip6 *ipv6) 187ip6_checkentry(const struct ip6t_ip6 *ipv6)
187{ 188{
188 if (ipv6->flags & ~IP6T_F_MASK) { 189 if (ipv6->flags & ~IP6T_F_MASK) {
@@ -212,8 +213,9 @@ ip6t_error(struct sk_buff *skb,
212 return NF_DROP; 213 return NF_DROP;
213} 214}
214 215
215static inline 216/* Performance critical - called for every packet */
216bool do_match(struct ip6t_entry_match *m, 217static inline bool
218do_match(struct ip6t_entry_match *m,
217 const struct sk_buff *skb, 219 const struct sk_buff *skb,
218 const struct net_device *in, 220 const struct net_device *in,
219 const struct net_device *out, 221 const struct net_device *out,
@@ -236,6 +238,7 @@ get_entry(void *base, unsigned int offset)
236} 238}
237 239
238/* All zeroes == unconditional rule. */ 240/* All zeroes == unconditional rule. */
241/* Mildly perf critical (only if packet tracing is on) */
239static inline int 242static inline int
240unconditional(const struct ip6t_ip6 *ipv6) 243unconditional(const struct ip6t_ip6 *ipv6)
241{ 244{
@@ -251,7 +254,7 @@ unconditional(const struct ip6t_ip6 *ipv6)
251#if defined(CONFIG_NETFILTER_XT_TARGET_TRACE) || \ 254#if defined(CONFIG_NETFILTER_XT_TARGET_TRACE) || \
252 defined(CONFIG_NETFILTER_XT_TARGET_TRACE_MODULE) 255 defined(CONFIG_NETFILTER_XT_TARGET_TRACE_MODULE)
253/* This cries for unification! */ 256/* This cries for unification! */
254static const char *hooknames[] = { 257static const char *const hooknames[] = {
255 [NF_INET_PRE_ROUTING] = "PREROUTING", 258 [NF_INET_PRE_ROUTING] = "PREROUTING",
256 [NF_INET_LOCAL_IN] = "INPUT", 259 [NF_INET_LOCAL_IN] = "INPUT",
257 [NF_INET_FORWARD] = "FORWARD", 260 [NF_INET_FORWARD] = "FORWARD",
@@ -265,7 +268,7 @@ enum nf_ip_trace_comments {
265 NF_IP6_TRACE_COMMENT_POLICY, 268 NF_IP6_TRACE_COMMENT_POLICY,
266}; 269};
267 270
268static const char *comments[] = { 271static const char *const comments[] = {
269 [NF_IP6_TRACE_COMMENT_RULE] = "rule", 272 [NF_IP6_TRACE_COMMENT_RULE] = "rule",
270 [NF_IP6_TRACE_COMMENT_RETURN] = "return", 273 [NF_IP6_TRACE_COMMENT_RETURN] = "return",
271 [NF_IP6_TRACE_COMMENT_POLICY] = "policy", 274 [NF_IP6_TRACE_COMMENT_POLICY] = "policy",
@@ -281,6 +284,7 @@ static struct nf_loginfo trace_loginfo = {
281 }, 284 },
282}; 285};
283 286
287/* Mildly perf critical (only if packet tracing is on) */
284static inline int 288static inline int
285get_chainname_rulenum(struct ip6t_entry *s, struct ip6t_entry *e, 289get_chainname_rulenum(struct ip6t_entry *s, struct ip6t_entry *e,
286 char *hookname, char **chainname, 290 char *hookname, char **chainname,
@@ -595,7 +599,7 @@ mark_source_chains(struct xt_table_info *newinfo,
595 return 1; 599 return 1;
596} 600}
597 601
598static inline int 602static int
599cleanup_match(struct ip6t_entry_match *m, unsigned int *i) 603cleanup_match(struct ip6t_entry_match *m, unsigned int *i)
600{ 604{
601 if (i && (*i)-- == 0) 605 if (i && (*i)-- == 0)
@@ -607,7 +611,7 @@ cleanup_match(struct ip6t_entry_match *m, unsigned int *i)
607 return 0; 611 return 0;
608} 612}
609 613
610static inline int 614static int
611check_entry(struct ip6t_entry *e, const char *name) 615check_entry(struct ip6t_entry *e, const char *name)
612{ 616{
613 struct ip6t_entry_target *t; 617 struct ip6t_entry_target *t;
@@ -628,7 +632,7 @@ check_entry(struct ip6t_entry *e, const char *name)
628 return 0; 632 return 0;
629} 633}
630 634
631static inline int check_match(struct ip6t_entry_match *m, const char *name, 635static int check_match(struct ip6t_entry_match *m, const char *name,
632 const struct ip6t_ip6 *ipv6, 636 const struct ip6t_ip6 *ipv6,
633 unsigned int hookmask, unsigned int *i) 637 unsigned int hookmask, unsigned int *i)
634{ 638{
@@ -651,7 +655,7 @@ static inline int check_match(struct ip6t_entry_match *m, const char *name,
651 return ret; 655 return ret;
652} 656}
653 657
654static inline int 658static int
655find_check_match(struct ip6t_entry_match *m, 659find_check_match(struct ip6t_entry_match *m,
656 const char *name, 660 const char *name,
657 const struct ip6t_ip6 *ipv6, 661 const struct ip6t_ip6 *ipv6,
@@ -680,7 +684,7 @@ err:
680 return ret; 684 return ret;
681} 685}
682 686
683static inline int check_target(struct ip6t_entry *e, const char *name) 687static int check_target(struct ip6t_entry *e, const char *name)
684{ 688{
685 struct ip6t_entry_target *t; 689 struct ip6t_entry_target *t;
686 struct xt_target *target; 690 struct xt_target *target;
@@ -701,7 +705,7 @@ static inline int check_target(struct ip6t_entry *e, const char *name)
701 return ret; 705 return ret;
702} 706}
703 707
704static inline int 708static int
705find_check_entry(struct ip6t_entry *e, const char *name, unsigned int size, 709find_check_entry(struct ip6t_entry *e, const char *name, unsigned int size,
706 unsigned int *i) 710 unsigned int *i)
707{ 711{
@@ -745,7 +749,7 @@ find_check_entry(struct ip6t_entry *e, const char *name, unsigned int size,
745 return ret; 749 return ret;
746} 750}
747 751
748static inline int 752static int
749check_entry_size_and_hooks(struct ip6t_entry *e, 753check_entry_size_and_hooks(struct ip6t_entry *e,
750 struct xt_table_info *newinfo, 754 struct xt_table_info *newinfo,
751 unsigned char *base, 755 unsigned char *base,
@@ -788,7 +792,7 @@ check_entry_size_and_hooks(struct ip6t_entry *e,
788 return 0; 792 return 0;
789} 793}
790 794
791static inline int 795static int
792cleanup_entry(struct ip6t_entry *e, unsigned int *i) 796cleanup_entry(struct ip6t_entry *e, unsigned int *i)
793{ 797{
794 struct ip6t_entry_target *t; 798 struct ip6t_entry_target *t;
@@ -944,7 +948,7 @@ get_counters(const struct xt_table_info *t,
944 } 948 }
945} 949}
946 950
947static inline struct xt_counters *alloc_counters(struct xt_table *table) 951static struct xt_counters *alloc_counters(struct xt_table *table)
948{ 952{
949 unsigned int countersize; 953 unsigned int countersize;
950 struct xt_counters *counters; 954 struct xt_counters *counters;
@@ -1494,7 +1498,7 @@ out:
1494 return ret; 1498 return ret;
1495} 1499}
1496 1500
1497static inline int 1501static int
1498compat_find_calc_match(struct ip6t_entry_match *m, 1502compat_find_calc_match(struct ip6t_entry_match *m,
1499 const char *name, 1503 const char *name,
1500 const struct ip6t_ip6 *ipv6, 1504 const struct ip6t_ip6 *ipv6,
@@ -1518,7 +1522,7 @@ compat_find_calc_match(struct ip6t_entry_match *m,
1518 return 0; 1522 return 0;
1519} 1523}
1520 1524
1521static inline int 1525static int
1522compat_release_match(struct ip6t_entry_match *m, unsigned int *i) 1526compat_release_match(struct ip6t_entry_match *m, unsigned int *i)
1523{ 1527{
1524 if (i && (*i)-- == 0) 1528 if (i && (*i)-- == 0)
@@ -1528,7 +1532,7 @@ compat_release_match(struct ip6t_entry_match *m, unsigned int *i)
1528 return 0; 1532 return 0;
1529} 1533}
1530 1534
1531static inline int 1535static int
1532compat_release_entry(struct compat_ip6t_entry *e, unsigned int *i) 1536compat_release_entry(struct compat_ip6t_entry *e, unsigned int *i)
1533{ 1537{
1534 struct ip6t_entry_target *t; 1538 struct ip6t_entry_target *t;
@@ -1543,7 +1547,7 @@ compat_release_entry(struct compat_ip6t_entry *e, unsigned int *i)
1543 return 0; 1547 return 0;
1544} 1548}
1545 1549
1546static inline int 1550static int
1547check_compat_entry_size_and_hooks(struct compat_ip6t_entry *e, 1551check_compat_entry_size_and_hooks(struct compat_ip6t_entry *e,
1548 struct xt_table_info *newinfo, 1552 struct xt_table_info *newinfo,
1549 unsigned int *size, 1553 unsigned int *size,
@@ -1666,7 +1670,7 @@ compat_copy_entry_from_user(struct compat_ip6t_entry *e, void **dstptr,
1666 return ret; 1670 return ret;
1667} 1671}
1668 1672
1669static inline int compat_check_entry(struct ip6t_entry *e, const char *name, 1673static int compat_check_entry(struct ip6t_entry *e, const char *name,
1670 unsigned int *i) 1674 unsigned int *i)
1671{ 1675{
1672 int j, ret; 1676 int j, ret;