/* Resolve clashes on insertion races. */
        bool allow_clash;
 
+       /* protoinfo nlattr size, closes a hole */
+       u16 nlattr_size;
+
        /* Try to fill in the third arg: dataoff is offset past network protocol
            hdr.  Return true if possible. */
        bool (*pkt_to_tuple)(const struct sk_buff *skb, unsigned int dataoff,
        /* convert protoinfo to nfnetink attributes */
        int (*to_nlattr)(struct sk_buff *skb, struct nlattr *nla,
                         struct nf_conn *ct);
-       /* Calculate protoinfo nlattr size */
-       int (*nlattr_size)(void);
 
        /* convert nfnetlink attributes to protoinfo */
        int (*from_nlattr)(struct nlattr *tb[], struct nf_conn *ct);
                               struct nf_conntrack_tuple *t);
        const struct nla_policy *nla_policy;
 
-       size_t nla_size;
-
 #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT)
        struct {
                int (*nlattr_to_obj)(struct nlattr *tb[],
 
        len *= 3u; /* ORIG, REPLY, MASTER */
 
        l4proto = __nf_ct_l4proto_find(nf_ct_l3num(ct), nf_ct_protonum(ct));
-       len += l4proto->nla_size;
+       len += l4proto->nlattr_size;
        if (l4proto->nlattr_tuple_size) {
                len4 = l4proto->nlattr_tuple_size();
                len4 *= 3u; /* ORIG, REPLY, MASTER */
 
        if (l4proto->l3proto >= ARRAY_SIZE(nf_ct_protos))
                return -EBUSY;
 
-       if ((l4proto->to_nlattr && !l4proto->nlattr_size) ||
+       if ((l4proto->to_nlattr && l4proto->nlattr_size == 0) ||
            (l4proto->tuple_to_nlattr && !l4proto->nlattr_tuple_size))
                return -EINVAL;
 
                goto out_unlock;
        }
 
-       l4proto->nla_size = 0;
-       if (l4proto->nlattr_size)
-               l4proto->nla_size += l4proto->nlattr_size();
-
        rcu_assign_pointer(nf_ct_protos[l4proto->l3proto][l4proto->l4proto],
                           l4proto);
 out_unlock:
 
        [CTA_PROTOINFO_DCCP_PAD]        = { .type = NLA_UNSPEC },
 };
 
+#define DCCP_NLATTR_SIZE ( \
+       NLA_ALIGN(NLA_HDRLEN + 1) + \
+       NLA_ALIGN(NLA_HDRLEN + 1) + \
+       NLA_ALIGN(NLA_HDRLEN + sizeof(u64)) + \
+       NLA_ALIGN(NLA_HDRLEN + 0))
+
 static int nlattr_to_dccp(struct nlattr *cda[], struct nf_conn *ct)
 {
        struct nlattr *attr = cda[CTA_PROTOINFO_DCCP];
        spin_unlock_bh(&ct->lock);
        return 0;
 }
-
-static int dccp_nlattr_size(void)
-{
-       return nla_total_size(0)        /* CTA_PROTOINFO_DCCP */
-               + nla_policy_len(dccp_nla_policy, CTA_PROTOINFO_DCCP_MAX + 1);
-}
-
 #endif
 
 #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT)
        .print_conntrack        = dccp_print_conntrack,
 #endif
 #if IS_ENABLED(CONFIG_NF_CT_NETLINK)
+       .nlattr_size            = DCCP_NLATTR_SIZE,
        .to_nlattr              = dccp_to_nlattr,
-       .nlattr_size            = dccp_nlattr_size,
        .from_nlattr            = nlattr_to_dccp,
        .tuple_to_nlattr        = nf_ct_port_tuple_to_nlattr,
        .nlattr_tuple_size      = nf_ct_port_nlattr_tuple_size,
        .print_conntrack        = dccp_print_conntrack,
 #endif
 #if IS_ENABLED(CONFIG_NF_CT_NETLINK)
+       .nlattr_size            = DCCP_NLATTR_SIZE,
        .to_nlattr              = dccp_to_nlattr,
-       .nlattr_size            = dccp_nlattr_size,
        .from_nlattr            = nlattr_to_dccp,
        .tuple_to_nlattr        = nf_ct_port_tuple_to_nlattr,
        .nlattr_tuple_size      = nf_ct_port_nlattr_tuple_size,
 
        [CTA_PROTOINFO_SCTP_VTAG_REPLY]     = { .type = NLA_U32 },
 };
 
+#define SCTP_NLATTR_SIZE ( \
+               NLA_ALIGN(NLA_HDRLEN + 1) + \
+               NLA_ALIGN(NLA_HDRLEN + 4) + \
+               NLA_ALIGN(NLA_HDRLEN + 4))
+
 static int nlattr_to_sctp(struct nlattr *cda[], struct nf_conn *ct)
 {
        struct nlattr *attr = cda[CTA_PROTOINFO_SCTP];
 
        return 0;
 }
-
-static int sctp_nlattr_size(void)
-{
-       return nla_total_size(0)        /* CTA_PROTOINFO_SCTP */
-               + nla_policy_len(sctp_nla_policy, CTA_PROTOINFO_SCTP_MAX + 1);
-}
 #endif
 
 #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT)
        .can_early_drop         = sctp_can_early_drop,
        .me                     = THIS_MODULE,
 #if IS_ENABLED(CONFIG_NF_CT_NETLINK)
+       .nlattr_size            = SCTP_NLATTR_SIZE,
        .to_nlattr              = sctp_to_nlattr,
-       .nlattr_size            = sctp_nlattr_size,
        .from_nlattr            = nlattr_to_sctp,
        .tuple_to_nlattr        = nf_ct_port_tuple_to_nlattr,
        .nlattr_tuple_size      = nf_ct_port_nlattr_tuple_size,
        .can_early_drop         = sctp_can_early_drop,
        .me                     = THIS_MODULE,
 #if IS_ENABLED(CONFIG_NF_CT_NETLINK)
+       .nlattr_size            = SCTP_NLATTR_SIZE,
        .to_nlattr              = sctp_to_nlattr,
-       .nlattr_size            = sctp_nlattr_size,
        .from_nlattr            = nlattr_to_sctp,
        .tuple_to_nlattr        = nf_ct_port_tuple_to_nlattr,
        .nlattr_tuple_size      = nf_ct_port_nlattr_tuple_size,
 
        [CTA_PROTOINFO_TCP_FLAGS_REPLY]     = { .len =  sizeof(struct nf_ct_tcp_flags) },
 };
 
+#define TCP_NLATTR_SIZE        ( \
+       NLA_ALIGN(NLA_HDRLEN + 1) + \
+       NLA_ALIGN(NLA_HDRLEN + 1) + \
+       NLA_ALIGN(NLA_HDRLEN + sizeof(sizeof(struct nf_ct_tcp_flags))) + \
+       NLA_ALIGN(NLA_HDRLEN + sizeof(sizeof(struct nf_ct_tcp_flags))))
+
 static int nlattr_to_tcp(struct nlattr *cda[], struct nf_conn *ct)
 {
        struct nlattr *pattr = cda[CTA_PROTOINFO_TCP];
        return 0;
 }
 
-static int tcp_nlattr_size(void)
-{
-       return nla_total_size(0)           /* CTA_PROTOINFO_TCP */
-               + nla_policy_len(tcp_nla_policy, CTA_PROTOINFO_TCP_MAX + 1);
-}
-
 static unsigned int tcp_nlattr_tuple_size(void)
 {
        static unsigned int size __read_mostly;
        .can_early_drop         = tcp_can_early_drop,
 #if IS_ENABLED(CONFIG_NF_CT_NETLINK)
        .to_nlattr              = tcp_to_nlattr,
-       .nlattr_size            = tcp_nlattr_size,
        .from_nlattr            = nlattr_to_tcp,
        .tuple_to_nlattr        = nf_ct_port_tuple_to_nlattr,
        .nlattr_to_tuple        = nf_ct_port_nlattr_to_tuple,
        .nlattr_tuple_size      = tcp_nlattr_tuple_size,
+       .nlattr_size            = TCP_NLATTR_SIZE,
        .nla_policy             = nf_ct_port_nla_policy,
 #endif
 #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT)
        .error                  = tcp_error,
        .can_early_drop         = tcp_can_early_drop,
 #if IS_ENABLED(CONFIG_NF_CT_NETLINK)
+       .nlattr_size            = TCP_NLATTR_SIZE,
        .to_nlattr              = tcp_to_nlattr,
-       .nlattr_size            = tcp_nlattr_size,
        .from_nlattr            = nlattr_to_tcp,
        .tuple_to_nlattr        = nf_ct_port_tuple_to_nlattr,
        .nlattr_to_tuple        = nf_ct_port_nlattr_to_tuple,