netfilter: conntrack: remove protocol name from l4proto struct
authorFlorian Westphal <fw@strlen.de>
Fri, 11 Aug 2017 22:57:04 +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_l4proto.h
net/ipv4/netfilter/nf_conntrack_proto_icmp.c
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
net/netfilter/nf_conntrack_proto.c
net/netfilter/nf_conntrack_proto_dccp.c
net/netfilter/nf_conntrack_proto_generic.c
net/netfilter/nf_conntrack_proto_gre.c
net/netfilter/nf_conntrack_proto_sctp.c
net/netfilter/nf_conntrack_proto_tcp.c
net/netfilter/nf_conntrack_proto_udp.c
net/netfilter/nf_conntrack_standalone.c

index b6e27cafb1d93c18d580c29d8c2938aac5a8d822..47c16bae5e00335f76efc0243f33e0731f34d2f8 100644 (file)
@@ -108,9 +108,6 @@ struct nf_conntrack_l4proto {
        /* Return the per-net protocol part. */
        struct nf_proto_net *(*get_net_proto)(struct net *net);
 
-       /* Protocol name */
-       const char *name;
-
        /* Module (if any) which this is connected to. */
        struct module *me;
 };
index 73c591d8a9a8e5295000f702e1b32e6a643e30e0..fdbeb03e46009f5e64a6a74581034640ea2a79f9 100644 (file)
@@ -362,7 +362,6 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_icmp __read_mostly =
 {
        .l3proto                = PF_INET,
        .l4proto                = IPPROTO_ICMP,
-       .name                   = "icmp",
        .pkt_to_tuple           = icmp_pkt_to_tuple,
        .invert_tuple           = icmp_invert_tuple,
        .print_tuple            = icmp_print_tuple,
index d5f028e33f658bd62deb5b9b0737c33366a22a83..805ab122767ad9b4761b28da1ccee9387482f93c 100644 (file)
@@ -367,7 +367,6 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6 __read_mostly =
 {
        .l3proto                = PF_INET6,
        .l4proto                = IPPROTO_ICMPV6,
-       .name                   = "icmpv6",
        .pkt_to_tuple           = icmpv6_pkt_to_tuple,
        .invert_tuple           = icmpv6_invert_tuple,
        .print_tuple            = icmpv6_print_tuple,
index 85104a27cc8987cc952e8880952a53e8a9d0008f..0ecab7163d625a1c0243fcc2d8b9e4fac481d00b 100644 (file)
@@ -437,8 +437,8 @@ int nf_ct_l4proto_register(struct nf_conntrack_l4proto *l4proto[],
        }
        if (i != num_proto) {
                ver = l4proto[i]->l3proto == PF_INET6 ? 6 : 4;
-               pr_err("nf_conntrack_ipv%d: can't register %s%d proto.\n",
-                      ver, l4proto[i]->name, ver);
+               pr_err("nf_conntrack_ipv%d: can't register l4 %d proto.\n",
+                      ver, l4proto[i]->l4proto);
                nf_ct_l4proto_unregister(l4proto, i);
        }
        return ret;
@@ -458,8 +458,8 @@ int nf_ct_l4proto_pernet_register(struct net *net,
                        break;
        }
        if (i != num_proto) {
-               pr_err("nf_conntrack_%s%d: pernet registration failed\n",
-                      l4proto[i]->name,
+               pr_err("nf_conntrack_proto_%d %d: pernet registration failed\n",
+                      l4proto[i]->l4proto,
                       l4proto[i]->l3proto == PF_INET6 ? 6 : 4);
                nf_ct_l4proto_pernet_unregister(net, l4proto, i);
        }
index 4707d997558af98a2057c418348f1776667ec606..a0492184a0a87ccf04b942b3157199dfa8c96d46 100644 (file)
@@ -880,7 +880,6 @@ static struct nf_proto_net *dccp_get_net_proto(struct net *net)
 struct nf_conntrack_l4proto nf_conntrack_l4proto_dccp4 __read_mostly = {
        .l3proto                = AF_INET,
        .l4proto                = IPPROTO_DCCP,
-       .name                   = "dccp",
        .pkt_to_tuple           = dccp_pkt_to_tuple,
        .invert_tuple           = dccp_invert_tuple,
        .new                    = dccp_new,
@@ -916,7 +915,6 @@ EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_dccp4);
 struct nf_conntrack_l4proto nf_conntrack_l4proto_dccp6 __read_mostly = {
        .l3proto                = AF_INET6,
        .l4proto                = IPPROTO_DCCP,
-       .name                   = "dccp",
        .pkt_to_tuple           = dccp_pkt_to_tuple,
        .invert_tuple           = dccp_invert_tuple,
        .new                    = dccp_new,
index d5868bad33a7ef1fd85e4dfffe024041d048d00a..4fe8b3312823a9fde68dd03cb41d062800b5f0a4 100644 (file)
@@ -187,7 +187,6 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_generic __read_mostly =
 {
        .l3proto                = PF_UNSPEC,
        .l4proto                = 255,
-       .name                   = "unknown",
        .pkt_to_tuple           = generic_pkt_to_tuple,
        .invert_tuple           = generic_invert_tuple,
        .print_tuple            = generic_print_tuple,
index 87bb40a3feb58e371e3fc899ab7c8b4dd2f38859..984bcfdbd4d780f6cacbea70eae1791224b440f2 100644 (file)
@@ -364,7 +364,6 @@ static int gre_init_net(struct net *net, u_int16_t proto)
 static struct nf_conntrack_l4proto nf_conntrack_l4proto_gre4 __read_mostly = {
        .l3proto         = AF_INET,
        .l4proto         = IPPROTO_GRE,
-       .name            = "gre",
        .pkt_to_tuple    = gre_pkt_to_tuple,
        .invert_tuple    = gre_invert_tuple,
        .print_tuple     = gre_print_tuple,
index 6eef29d2eec4090efbe654baf4190137417fd943..1d7a995ea049c120765500c2a9cb799785e9c6da 100644 (file)
@@ -791,7 +791,6 @@ static struct nf_proto_net *sctp_get_net_proto(struct net *net)
 struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp4 __read_mostly = {
        .l3proto                = PF_INET,
        .l4proto                = IPPROTO_SCTP,
-       .name                   = "sctp",
        .pkt_to_tuple           = sctp_pkt_to_tuple,
        .invert_tuple           = sctp_invert_tuple,
        .print_tuple            = sctp_print_tuple,
@@ -828,7 +827,6 @@ EXPORT_SYMBOL_GPL(nf_conntrack_l4proto_sctp4);
 struct nf_conntrack_l4proto nf_conntrack_l4proto_sctp6 __read_mostly = {
        .l3proto                = PF_INET6,
        .l4proto                = IPPROTO_SCTP,
-       .name                   = "sctp",
        .pkt_to_tuple           = sctp_pkt_to_tuple,
        .invert_tuple           = sctp_invert_tuple,
        .print_tuple            = sctp_print_tuple,
index 9758a7dfd83ef95c0bcab1257d63cb38d9faed88..e3e59e3d0592ce8e36f0dd182597a2b3c5ab14b0 100644 (file)
@@ -1556,7 +1556,6 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp4 __read_mostly =
 {
        .l3proto                = PF_INET,
        .l4proto                = IPPROTO_TCP,
-       .name                   = "tcp",
        .pkt_to_tuple           = tcp_pkt_to_tuple,
        .invert_tuple           = tcp_invert_tuple,
        .print_tuple            = tcp_print_tuple,
@@ -1594,7 +1593,6 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6 __read_mostly =
 {
        .l3proto                = PF_INET6,
        .l4proto                = IPPROTO_TCP,
-       .name                   = "tcp",
        .pkt_to_tuple           = tcp_pkt_to_tuple,
        .invert_tuple           = tcp_invert_tuple,
        .print_tuple            = tcp_print_tuple,
index f6ebce6178ca65d040382af45bc962862b883d4a..ec861a1169f103f4a1b9e9e8ab4c6b73b8c2d2f5 100644 (file)
@@ -313,7 +313,6 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_udp4 __read_mostly =
 {
        .l3proto                = PF_INET,
        .l4proto                = IPPROTO_UDP,
-       .name                   = "udp",
        .allow_clash            = true,
        .pkt_to_tuple           = udp_pkt_to_tuple,
        .invert_tuple           = udp_invert_tuple,
@@ -347,7 +346,6 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite4 __read_mostly =
 {
        .l3proto                = PF_INET,
        .l4proto                = IPPROTO_UDPLITE,
-       .name                   = "udplite",
        .allow_clash            = true,
        .pkt_to_tuple           = udp_pkt_to_tuple,
        .invert_tuple           = udp_invert_tuple,
@@ -381,7 +379,6 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6 __read_mostly =
 {
        .l3proto                = PF_INET6,
        .l4proto                = IPPROTO_UDP,
-       .name                   = "udp",
        .allow_clash            = true,
        .pkt_to_tuple           = udp_pkt_to_tuple,
        .invert_tuple           = udp_invert_tuple,
@@ -415,7 +412,6 @@ struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite6 __read_mostly =
 {
        .l3proto                = PF_INET6,
        .l4proto                = IPPROTO_UDPLITE,
-       .name                   = "udplite",
        .allow_clash            = true,
        .pkt_to_tuple           = udp_pkt_to_tuple,
        .invert_tuple           = udp_invert_tuple,
index 359d7e6a4503d6765e20fa5e2bbdd7e49d415d1a..b28f9e93f574e7903962b01caa3d46f7f07326a1 100644 (file)
@@ -208,6 +208,21 @@ static const char* l3proto_name(u16 proto)
        return "unknown";
 }
 
+static const char* l4proto_name(u16 proto)
+{
+       switch (proto) {
+       case IPPROTO_ICMP: return "icmp";
+       case IPPROTO_TCP: return "tcp";
+       case IPPROTO_UDP: return "udp";
+       case IPPROTO_DCCP: return "dccp";
+       case IPPROTO_GRE: return "gre";
+       case IPPROTO_SCTP: return "sctp";
+       case IPPROTO_UDPLITE: return "udplite";
+       }
+
+       return "unknown";
+}
+
 /* return 0 on success, 1 in case of error */
 static int ct_seq_show(struct seq_file *s, void *v)
 {
@@ -242,7 +257,7 @@ static int ct_seq_show(struct seq_file *s, void *v)
        ret = -ENOSPC;
        seq_printf(s, "%-8s %u %-8s %u %ld ",
                   l3proto_name(l3proto->l3proto), nf_ct_l3num(ct),
-                  l4proto->name, nf_ct_protonum(ct),
+                  l4proto_name(l4proto->l4proto), nf_ct_protonum(ct),
                   nf_ct_expires(ct)  / HZ);
 
        if (l4proto->print_conntrack)