netfilter: conntrack: remove protocol name from l3proto struct
authorFlorian Westphal <fw@strlen.de>
Fri, 11 Aug 2017 22:57:03 +0000 (00:57 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 24 Aug 2017 16:52:32 +0000 (18:52 +0200)
no need to waste storage for something that is only needed
in one place and can be deduced from protocol number.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/net/netfilter/nf_conntrack_l3proto.h
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
net/netfilter/nf_conntrack_l3proto_generic.c
net/netfilter/nf_conntrack_standalone.c

index 6a27ffea7480be4c39f7357e414bec2fc34077a3..e31861e4fa6aa97406571152a54cce07012cf463 100644 (file)
@@ -23,9 +23,6 @@ struct nf_conntrack_l3proto {
        /* size of tuple nlattr, fills a hole */
        u16 nla_size;
 
-       /* Protocol name */
-       const char *name;
-
        /*
         * Try to fill in the third arg: nhoff is offset of l3 proto
          * hdr.  Return true if possible.
index 9fb8cb033d80434cdb6c64c65ee0b7e597616890..9f7ea862068caba373b2b42f39d0c53d478509dc 100644 (file)
@@ -353,7 +353,6 @@ static void ipv4_hooks_unregister(struct net *net)
 
 struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4 __read_mostly = {
        .l3proto         = PF_INET,
-       .name            = "ipv4",
        .pkt_to_tuple    = ipv4_pkt_to_tuple,
        .invert_tuple    = ipv4_invert_tuple,
        .print_tuple     = ipv4_print_tuple,
index 6b4d59fd021474c0332ec7164a76583b7078beab..91d37fbe28de5717eba86804de3a2b11579c4454 100644 (file)
@@ -348,7 +348,6 @@ static void ipv6_hooks_unregister(struct net *net)
 
 struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6 __read_mostly = {
        .l3proto                = PF_INET6,
-       .name                   = "ipv6",
        .pkt_to_tuple           = ipv6_pkt_to_tuple,
        .invert_tuple           = ipv6_invert_tuple,
        .print_tuple            = ipv6_print_tuple,
index cf9ace70bececf1573d8ef2d6d75387155dc6258..0387971582bc4e60dc7d00e8b98fd28411135af5 100644 (file)
@@ -64,7 +64,6 @@ static int generic_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
 
 struct nf_conntrack_l3proto nf_conntrack_l3proto_generic __read_mostly = {
        .l3proto         = PF_UNSPEC,
-       .name            = "unknown",
        .pkt_to_tuple    = generic_pkt_to_tuple,
        .invert_tuple    = generic_invert_tuple,
        .print_tuple     = generic_print_tuple,
index 5b6c675d55b14b2392a75285a2d8f87b569c9b22..359d7e6a4503d6765e20fa5e2bbdd7e49d415d1a 100644 (file)
@@ -198,6 +198,16 @@ ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct)
 }
 #endif
 
+static const char* l3proto_name(u16 proto)
+{
+       switch (proto) {
+       case AF_INET: return "ipv4";
+       case AF_INET6: return "ipv6";
+       }
+
+       return "unknown";
+}
+
 /* return 0 on success, 1 in case of error */
 static int ct_seq_show(struct seq_file *s, void *v)
 {
@@ -231,7 +241,7 @@ static int ct_seq_show(struct seq_file *s, void *v)
 
        ret = -ENOSPC;
        seq_printf(s, "%-8s %u %-8s %u %ld ",
-                  l3proto->name, nf_ct_l3num(ct),
+                  l3proto_name(l3proto->l3proto), nf_ct_l3num(ct),
                   l4proto->name, nf_ct_protonum(ct),
                   nf_ct_expires(ct)  / HZ);