Skip to content

Commit 2398a97

Browse files
a3a3elummakynes
authored andcommitted
netfilter: ipset: move functions to ip_set_core.c.
Several inline functions in ip_set.h are only called in ip_set_core.c: move them and remove inline function specifier. Signed-off-by: Jeremy Sowden <jeremy@azazel.net> Acked-by: Jozsef Kadlecsik <kadlec@netfilter.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 94177f6 commit 2398a97

2 files changed

Lines changed: 102 additions & 102 deletions

File tree

‎include/linux/netfilter/ipset/ip_set.h‎

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -508,86 +508,9 @@ ip_set_timeout_set(unsigned long *timeout, u32 value)
508508
*timeout = t;
509509
}
510510

511-
static inline u32
512-
ip_set_timeout_get(const unsigned long *timeout)
513-
{
514-
u32 t;
515-
516-
if (*timeout == IPSET_ELEM_PERMANENT)
517-
return 0;
518-
519-
t = jiffies_to_msecs(*timeout - jiffies)/MSEC_PER_SEC;
520-
/* Zero value in userspace means no timeout */
521-
return t == 0 ? 1 : t;
522-
}
523-
524511
void ip_set_init_comment(struct ip_set *set, struct ip_set_comment *comment,
525512
const struct ip_set_ext *ext);
526513

527-
static inline void
528-
ip_set_add_bytes(u64 bytes, struct ip_set_counter *counter)
529-
{
530-
atomic64_add((long long)bytes, &(counter)->bytes);
531-
}
532-
533-
static inline void
534-
ip_set_add_packets(u64 packets, struct ip_set_counter *counter)
535-
{
536-
atomic64_add((long long)packets, &(counter)->packets);
537-
}
538-
539-
static inline u64
540-
ip_set_get_bytes(const struct ip_set_counter *counter)
541-
{
542-
return (u64)atomic64_read(&(counter)->bytes);
543-
}
544-
545-
static inline u64
546-
ip_set_get_packets(const struct ip_set_counter *counter)
547-
{
548-
return (u64)atomic64_read(&(counter)->packets);
549-
}
550-
551-
static inline bool
552-
ip_set_match_counter(u64 counter, u64 match, u8 op)
553-
{
554-
switch (op) {
555-
case IPSET_COUNTER_NONE:
556-
return true;
557-
case IPSET_COUNTER_EQ:
558-
return counter == match;
559-
case IPSET_COUNTER_NE:
560-
return counter != match;
561-
case IPSET_COUNTER_LT:
562-
return counter < match;
563-
case IPSET_COUNTER_GT:
564-
return counter > match;
565-
}
566-
return false;
567-
}
568-
569-
static inline void
570-
ip_set_update_counter(struct ip_set_counter *counter,
571-
const struct ip_set_ext *ext, u32 flags)
572-
{
573-
if (ext->packets != ULLONG_MAX &&
574-
!(flags & IPSET_FLAG_SKIP_COUNTER_UPDATE)) {
575-
ip_set_add_bytes(ext->bytes, counter);
576-
ip_set_add_packets(ext->packets, counter);
577-
}
578-
}
579-
580-
static inline bool
581-
ip_set_put_counter(struct sk_buff *skb, const struct ip_set_counter *counter)
582-
{
583-
return nla_put_net64(skb, IPSET_ATTR_BYTES,
584-
cpu_to_be64(ip_set_get_bytes(counter)),
585-
IPSET_ATTR_PAD) ||
586-
nla_put_net64(skb, IPSET_ATTR_PACKETS,
587-
cpu_to_be64(ip_set_get_packets(counter)),
588-
IPSET_ATTR_PAD);
589-
}
590-
591514
static inline void
592515
ip_set_init_counter(struct ip_set_counter *counter,
593516
const struct ip_set_ext *ext)
@@ -598,31 +521,6 @@ ip_set_init_counter(struct ip_set_counter *counter,
598521
atomic64_set(&(counter)->packets, (long long)(ext->packets));
599522
}
600523

601-
static inline void
602-
ip_set_get_skbinfo(struct ip_set_skbinfo *skbinfo,
603-
const struct ip_set_ext *ext,
604-
struct ip_set_ext *mext, u32 flags)
605-
{
606-
mext->skbinfo = *skbinfo;
607-
}
608-
609-
static inline bool
610-
ip_set_put_skbinfo(struct sk_buff *skb, const struct ip_set_skbinfo *skbinfo)
611-
{
612-
/* Send nonzero parameters only */
613-
return ((skbinfo->skbmark || skbinfo->skbmarkmask) &&
614-
nla_put_net64(skb, IPSET_ATTR_SKBMARK,
615-
cpu_to_be64((u64)skbinfo->skbmark << 32 |
616-
skbinfo->skbmarkmask),
617-
IPSET_ATTR_PAD)) ||
618-
(skbinfo->skbprio &&
619-
nla_put_net32(skb, IPSET_ATTR_SKBPRIO,
620-
cpu_to_be32(skbinfo->skbprio))) ||
621-
(skbinfo->skbqueue &&
622-
nla_put_net16(skb, IPSET_ATTR_SKBQUEUE,
623-
cpu_to_be16(skbinfo->skbqueue)));
624-
}
625-
626524
static inline void
627525
ip_set_init_skbinfo(struct ip_set_skbinfo *skbinfo,
628526
const struct ip_set_ext *ext)

‎net/netfilter/ipset/ip_set_core.c‎

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,19 @@ ip_set_get_ipaddr6(struct nlattr *nla, union nf_inet_addr *ipaddr)
325325
}
326326
EXPORT_SYMBOL_GPL(ip_set_get_ipaddr6);
327327

328+
static u32
329+
ip_set_timeout_get(const unsigned long *timeout)
330+
{
331+
u32 t;
332+
333+
if (*timeout == IPSET_ELEM_PERMANENT)
334+
return 0;
335+
336+
t = jiffies_to_msecs(*timeout - jiffies) / MSEC_PER_SEC;
337+
/* Zero value in userspace means no timeout */
338+
return t == 0 ? 1 : t;
339+
}
340+
328341
static char *
329342
ip_set_comment_uget(struct nlattr *tb)
330343
{
@@ -510,6 +523,46 @@ ip_set_get_extensions(struct ip_set *set, struct nlattr *tb[],
510523
}
511524
EXPORT_SYMBOL_GPL(ip_set_get_extensions);
512525

526+
static u64
527+
ip_set_get_bytes(const struct ip_set_counter *counter)
528+
{
529+
return (u64)atomic64_read(&(counter)->bytes);
530+
}
531+
532+
static u64
533+
ip_set_get_packets(const struct ip_set_counter *counter)
534+
{
535+
return (u64)atomic64_read(&(counter)->packets);
536+
}
537+
538+
static bool
539+
ip_set_put_counter(struct sk_buff *skb, const struct ip_set_counter *counter)
540+
{
541+
return nla_put_net64(skb, IPSET_ATTR_BYTES,
542+
cpu_to_be64(ip_set_get_bytes(counter)),
543+
IPSET_ATTR_PAD) ||
544+
nla_put_net64(skb, IPSET_ATTR_PACKETS,
545+
cpu_to_be64(ip_set_get_packets(counter)),
546+
IPSET_ATTR_PAD);
547+
}
548+
549+
static bool
550+
ip_set_put_skbinfo(struct sk_buff *skb, const struct ip_set_skbinfo *skbinfo)
551+
{
552+
/* Send nonzero parameters only */
553+
return ((skbinfo->skbmark || skbinfo->skbmarkmask) &&
554+
nla_put_net64(skb, IPSET_ATTR_SKBMARK,
555+
cpu_to_be64((u64)skbinfo->skbmark << 32 |
556+
skbinfo->skbmarkmask),
557+
IPSET_ATTR_PAD)) ||
558+
(skbinfo->skbprio &&
559+
nla_put_net32(skb, IPSET_ATTR_SKBPRIO,
560+
cpu_to_be32(skbinfo->skbprio))) ||
561+
(skbinfo->skbqueue &&
562+
nla_put_net16(skb, IPSET_ATTR_SKBQUEUE,
563+
cpu_to_be16(skbinfo->skbqueue)));
564+
}
565+
513566
int
514567
ip_set_put_extensions(struct sk_buff *skb, const struct ip_set *set,
515568
const void *e, bool active)
@@ -535,6 +588,55 @@ ip_set_put_extensions(struct sk_buff *skb, const struct ip_set *set,
535588
}
536589
EXPORT_SYMBOL_GPL(ip_set_put_extensions);
537590

591+
static bool
592+
ip_set_match_counter(u64 counter, u64 match, u8 op)
593+
{
594+
switch (op) {
595+
case IPSET_COUNTER_NONE:
596+
return true;
597+
case IPSET_COUNTER_EQ:
598+
return counter == match;
599+
case IPSET_COUNTER_NE:
600+
return counter != match;
601+
case IPSET_COUNTER_LT:
602+
return counter < match;
603+
case IPSET_COUNTER_GT:
604+
return counter > match;
605+
}
606+
return false;
607+
}
608+
609+
static void
610+
ip_set_add_bytes(u64 bytes, struct ip_set_counter *counter)
611+
{
612+
atomic64_add((long long)bytes, &(counter)->bytes);
613+
}
614+
615+
static void
616+
ip_set_add_packets(u64 packets, struct ip_set_counter *counter)
617+
{
618+
atomic64_add((long long)packets, &(counter)->packets);
619+
}
620+
621+
static void
622+
ip_set_update_counter(struct ip_set_counter *counter,
623+
const struct ip_set_ext *ext, u32 flags)
624+
{
625+
if (ext->packets != ULLONG_MAX &&
626+
!(flags & IPSET_FLAG_SKIP_COUNTER_UPDATE)) {
627+
ip_set_add_bytes(ext->bytes, counter);
628+
ip_set_add_packets(ext->packets, counter);
629+
}
630+
}
631+
632+
static void
633+
ip_set_get_skbinfo(struct ip_set_skbinfo *skbinfo,
634+
const struct ip_set_ext *ext,
635+
struct ip_set_ext *mext, u32 flags)
636+
{
637+
mext->skbinfo = *skbinfo;
638+
}
639+
538640
bool
539641
ip_set_match_extensions(struct ip_set *set, const struct ip_set_ext *ext,
540642
struct ip_set_ext *mext, u32 flags, void *data)

0 commit comments

Comments
 (0)