smack: remove duplicated hook function
Subsystems (2)
PATCH 1/1 smack: remove duplicated hook function
ipv4 and ipv6 hook functions are identical, remove one.
---
patch targets next branch of
git://github.com/cschaufler/smack-next.
security/smack/smack_netfilter.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-)
security/smack/smack_netfilter.c +3 -23
@@ -18,27 +18,7 @@#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_hook_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_hook_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_hook_output, .pf =NFPROTO_IPV6 , .hooknum =NF_INET_LOCAL_OUT , .priority =NF_IP6_PRI_SELINUX_FIRST ,
Signature · 1 line
2.32.0
Casey Schaufler
maintainerQuoted 3 lines · Florian Westphal
ipv4 and ipv6 hook functions are identical, remove one.
Signed-off-by Florian Westphal <[email protected]>
Looks fine, with the one change I've noted below. If you're OK with that change I can take it for smack-next.
Quoted 27 lines
---
patch targets next branch of
git://github.com/cschaufler/smack-next.security/smack/smack_netfilter.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-)security/smack/smack_netfilter.c +0
-12@@ -18,27 +18,7 @@#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;
security/smack/smack_netfilter.c line 21
Quoted 10 lines
security/smack/smack_netfilter.c +1
-9- 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_hook_output(void *priv,
I would prefer smack_ip_output() to smack_hook_output().
Quoted 20 lines
security/smack/smack_netfilter.c +2
-2struct 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_hook_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_hook_output, .pf =NFPROTO_IPV6 , .hooknum =NF_INET_LOCAL_OUT , .priority =NF_IP6_PRI_SELINUX_FIRST ,
Quoted 4 lines · Casey Schaufler
Quoted 1 line
Signed-off-by Florian Westphal <[email protected]>Looks fine, with the one change I've noted below. If you're OK with that change I can take it for smack-next.
Sure, smack_ip_output() is fine.
Casey Schaufler
maintainerQuoted 5 lines · Florian Westphal
Quoted 3 lines · Casey Schaufler
Quoted 1 line
Signed-off-by Florian Westphal <[email protected]>Looks fine, with the one change I've noted below. If you're OK with that change I can take it for smack-next.
Sure,
smack_ip_output()is fine.
Added to smack-next#next. Thank you.