netfilter: xtables: move extension arguments into compound structure (3/6)
[deliverable/linux.git] / net / netfilter / xt_recent.c
index adc2e2f1b09c6c3511b73822aea819c026353fa7..4ebd4ca9a991bf871a23bf672ea2b30d5a9095d7 100644 (file)
@@ -124,7 +124,7 @@ recent_entry_lookup(const struct recent_table *table,
        struct recent_entry *e;
        unsigned int h;
 
-       if (family == AF_INET)
+       if (family == NFPROTO_IPV4)
                h = recent_entry_hash4(addrp);
        else
                h = recent_entry_hash6(addrp);
@@ -165,7 +165,7 @@ recent_entry_init(struct recent_table *t, const union nf_inet_addr *addr,
        e->nstamps   = 1;
        e->index     = 1;
        e->family    = family;
-       if (family == AF_INET)
+       if (family == NFPROTO_IPV4)
                list_add_tail(&e->list, &t->iphash[recent_entry_hash4(addr)]);
        else
                list_add_tail(&e->list, &t->iphash[recent_entry_hash6(addr)]);
@@ -204,19 +204,16 @@ static void recent_table_flush(struct recent_table *t)
 }
 
 static bool
-recent_mt(const struct sk_buff *skb, const struct net_device *in,
-          const struct net_device *out, const struct xt_match *match,
-          const void *matchinfo, int offset, unsigned int protoff,
-          bool *hotdrop)
+recent_mt(const struct sk_buff *skb, const struct xt_match_param *par)
 {
-       const struct xt_recent_mtinfo *info = matchinfo;
+       const struct xt_recent_mtinfo *info = par->matchinfo;
        struct recent_table *t;
        struct recent_entry *e;
        union nf_inet_addr addr = {};
        u_int8_t ttl;
        bool ret = info->invert;
 
-       if (match->family == AF_INET) {
+       if (par->match->family == NFPROTO_IPV4) {
                const struct iphdr *iph = ip_hdr(skb);
 
                if (info->side == XT_RECENT_DEST)
@@ -237,19 +234,19 @@ recent_mt(const struct sk_buff *skb, const struct net_device *in,
        }
 
        /* use TTL as seen before forwarding */
-       if (out && !skb->sk)
+       if (par->out != NULL && skb->sk == NULL)
                ttl++;
 
        spin_lock_bh(&recent_lock);
        t = recent_table_lookup(info->name);
-       e = recent_entry_lookup(t, &addr, match->family,
+       e = recent_entry_lookup(t, &addr, par->match->family,
                                (info->check_set & XT_RECENT_TTL) ? ttl : 0);
        if (e == NULL) {
                if (!(info->check_set & XT_RECENT_SET))
                        goto out;
-               e = recent_entry_init(t, &addr, match->family, ttl);
+               e = recent_entry_init(t, &addr, par->match->family, ttl);
                if (e == NULL)
-                       *hotdrop = true;
+                       *par->hotdrop = true;
                ret = !ret;
                goto out;
        }
@@ -283,12 +280,9 @@ out:
        return ret;
 }
 
-static bool
-recent_mt_check(const char *tablename, const void *ip,
-                const struct xt_match *match, void *matchinfo,
-                unsigned int hook_mask)
+static bool recent_mt_check(const struct xt_mtchk_param *par)
 {
-       const struct xt_recent_mtinfo *info = matchinfo;
+       const struct xt_recent_mtinfo *info = par->matchinfo;
        struct recent_table *t;
        unsigned i;
        bool ret = false;
@@ -355,9 +349,9 @@ out:
        return ret;
 }
 
-static void recent_mt_destroy(const struct xt_match *match, void *matchinfo)
+static void recent_mt_destroy(const struct xt_mtdtor_param *par)
 {
-       const struct xt_recent_mtinfo *info = matchinfo;
+       const struct xt_recent_mtinfo *info = par->matchinfo;
        struct recent_table *t;
 
        mutex_lock(&recent_mutex);
@@ -429,7 +423,7 @@ static int recent_seq_show(struct seq_file *seq, void *v)
        unsigned int i;
 
        i = (e->index - 1) % ip_pkt_list_tot;
-       if (e->family == AF_INET)
+       if (e->family == NFPROTO_IPV4)
                seq_printf(seq, "src=" NIPQUAD_FMT " ttl: %u last_seen: %lu "
                           "oldest_pkt: %u", NIPQUAD(e->addr.ip), e->ttl,
                           e->stamps[i], e->index);
@@ -519,10 +513,11 @@ static ssize_t recent_old_proc_write(struct file *file,
        addr = in_aton(c);
 
        spin_lock_bh(&recent_lock);
-       e = recent_entry_lookup(t, (const void *)&addr, PF_INET, 0);
+       e = recent_entry_lookup(t, (const void *)&addr, NFPROTO_IPV4, 0);
        if (e == NULL) {
                if (add)
-                       recent_entry_init(t, (const void *)&addr, PF_INET, 0);
+                       recent_entry_init(t, (const void *)&addr,
+                                         NFPROTO_IPV4, 0);
        } else {
                if (add)
                        recent_entry_update(t, e);
@@ -585,10 +580,10 @@ recent_mt_proc_write(struct file *file, const char __user *input,
        ++c;
        --size;
        if (strnchr(c, size, ':') != NULL) {
-               family = AF_INET6;
+               family = NFPROTO_IPV6;
                succ   = in6_pton(c, size, (void *)&addr, '\n', NULL);
        } else {
-               family = AF_INET;
+               family = NFPROTO_IPV4;
                succ   = in4_pton(c, size, (void *)&addr, '\n', NULL);
        }
 
@@ -628,7 +623,7 @@ static struct xt_match recent_mt_reg[] __read_mostly = {
        {
                .name       = "recent",
                .revision   = 0,
-               .family     = AF_INET,
+               .family     = NFPROTO_IPV4,
                .match      = recent_mt,
                .matchsize  = sizeof(struct xt_recent_mtinfo),
                .checkentry = recent_mt_check,
@@ -638,7 +633,7 @@ static struct xt_match recent_mt_reg[] __read_mostly = {
        {
                .name       = "recent",
                .revision   = 0,
-               .family     = AF_INET6,
+               .family     = NFPROTO_IPV6,
                .match      = recent_mt,
                .matchsize  = sizeof(struct xt_recent_mtinfo),
                .checkentry = recent_mt_check,
This page took 0.0284 seconds and 5 git commands to generate.