smack: remove duplicated hook function
authorFlorian Westphal <fw@strlen.de>
Mon, 11 Oct 2021 14:33:09 +0000 (16:33 +0200)
committerCasey Schaufler <casey@schaufler-ca.com>
Tue, 12 Oct 2021 15:23:52 +0000 (08:23 -0700)
ipv4 and ipv6 hook functions are identical, remove one.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
security/smack/smack_netfilter.c

index fc7399b453738487332d0fdb0993a3fb6e557805..b945c1d3a7431a5a98bdce8da66dc3cb43ac7508 100644 (file)
 #include <net/net_namespace.h>
 #include "smack.h"
 
-#if IS_ENABLED(CONFIG_IPV6)
-
-static unsigned int smack_ipv6_output(void *priv,
-                                       struct sk_buff *skb,
-                                       const struct nf_hook_state *state)
-{
-       struct sock *sk = skb_to_full_sk(skb);
-       struct socket_smack *ssp;
-       struct smack_known *skp;
-
-       if (sk && sk->sk_security) {
-               ssp = sk->sk_security;
-               skp = ssp->smk_out;
-               skb->secmark = skp->smk_secid;
-       }
-
-       return NF_ACCEPT;
-}
-#endif /* IPV6 */
-
-static unsigned int smack_ipv4_output(void *priv,
+static unsigned int smack_ip_output(void *priv,
                                        struct sk_buff *skb,
                                        const struct nf_hook_state *state)
 {
@@ -57,14 +37,14 @@ static unsigned int smack_ipv4_output(void *priv,
 
 static const struct nf_hook_ops smack_nf_ops[] = {
        {
-               .hook =         smack_ipv4_output,
+               .hook =         smack_ip_output,
                .pf =           NFPROTO_IPV4,
                .hooknum =      NF_INET_LOCAL_OUT,
                .priority =     NF_IP_PRI_SELINUX_FIRST,
        },
 #if IS_ENABLED(CONFIG_IPV6)
        {
-               .hook =         smack_ipv6_output,
+               .hook =         smack_ip_output,
                .pf =           NFPROTO_IPV6,
                .hooknum =      NF_INET_LOCAL_OUT,
                .priority =     NF_IP6_PRI_SELINUX_FIRST,