From: "D. Wythe" <alibuda@xxxxxxxxxxxxxxxxx> Since smc_sock and tcp_sock coexist in inet version of smc, the sock flags field are shared between tcp and smc. Like the sk_state, we also need a extra sock flags filed for smc in inet version, and using the icsk field to determine which is the very field needed to be accessed or changed. Signed-off-by: D. Wythe <alibuda@xxxxxxxxxxxxxxxxx> --- net/smc/smc.h | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/net/smc/smc.h b/net/smc/smc.h index e54a30c..1675193 100644 --- a/net/smc/smc.h +++ b/net/smc/smc.h @@ -252,6 +252,7 @@ struct smc_sock { /* smc sock container */ }; struct socket *clcsock; /* internal tcp socket */ unsigned char smc_state; /* smc state used in smc via inet_sk */ + unsigned long smc_sk_flags; /* smc sock flags used for inet sock */ void (*clcsk_state_change)(struct sock *sk); /* original stat_change fct. */ void (*clcsk_data_ready)(struct sock *sk); @@ -385,10 +386,6 @@ void smc_fill_gid_list(struct smc_link_group *lgr, int smc_nl_enable_hs_limitation(struct sk_buff *skb, struct genl_info *info); int smc_nl_disable_hs_limitation(struct sk_buff *skb, struct genl_info *info); -static inline void smc_sock_set_flag(struct sock *sk, enum sock_flags flag) -{ - set_bit(flag, &sk->sk_flags); -} static __always_inline bool smc_sock_is_inet_sock(const struct sock *sk) { @@ -409,6 +406,33 @@ static __always_inline void smc_sk_set_state(struct sock *sk, unsigned char stat sk->sk_state = state; } -#define smc_sock_flag(sk, flag) sock_flag(sk, flag) +static __always_inline bool smc_sock_flag(const struct sock *sk, enum sock_flags flag) +{ + if (smc_sock_is_inet_sock(sk)) { + switch (flag) { + case SOCK_DEAD: + case SOCK_DONE: + return test_bit(flag, &smc_sk(sk)->smc_sk_flags); + default: + break; + } + } + return sock_flag(sk, flag); +} + +static __always_inline void smc_sock_set_flag(struct sock *sk, enum sock_flags flag) +{ + if (smc_sock_is_inet_sock(sk)) { + switch (flag) { + case SOCK_DEAD: + case SOCK_DONE: + __set_bit(flag, &smc_sk(sk)->smc_sk_flags); + return; + default: + break; + } + } + set_bit(flag, &sk->sk_flags); +} #endif /* __SMC_H */ -- 1.8.3.1