pppox: remove sk_pppox() helper
PATCH v2 1/2 pppox: remove sk_pppox() helper
The sk member can be directly accessed from struct pppox_sock without relying on type casting. Remove the sk_pppox() helper and update all call sites to use po->sk directly.
---
Changes in v2: none
Link to v1: https://lore.kernel.org/r/[email protected]
drivers/net/ppp/pppoe.c | 10 +++++----- drivers/net/ppp/pptp.c | 6 +++--- include/linux/if_pppox.h | 5 ----- 3 files changed, 8 insertions(+), 13 deletions(-)
drivers/net/ppp/pppoe.c +5 -5
@@ -231,7 +231,7 @@ static inline struct pppox_sock *get_item(struct pppoe_net *pn, __be16 sid,struct pppox_sock *po; po =__get_item (pn, sid, addr, ifindex); -if (po && !refcount_inc_not_zero (&sk_pppox (po)->sk_refcnt)) +if (po && !refcount_inc_not_zero (&po->sk.sk_refcnt)) po =NULL ;return po;
@@ -273,7 +273,7 @@ static void pppoe_flush_dev(struct net_device *dev)if (!po)break ; - sk =sk_pppox (po); + sk = &po->sk;/* We always grab the socket lock, followed by the * hash_lock, in that order. Since we should hold the
@@ -413,7 +413,7 @@ static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev,if (!po) goto drop; -return __sk_receive_skb (sk_pppox (po), skb,0 ,1 , false); +return __sk_receive_skb (&po->sk, skb,0 ,1 , false); drop:kfree_skb (skb);
@@ -425,7 +425,7 @@ static void pppoe_unbind_sock_work(struct work_struct *work) { struct pppox_sock *po = container_of(work, struct pppox_sock, proto.pppoe.padt_work); -struct sock *sk =sk_pppox (po); +struct sock *sk = &po->sk;lock_sock (sk);if (po->pppoe_dev) {
@@ -469,7 +469,7 @@ static int pppoe_disc_rcv(struct sk_buff *skb, struct net_device *dev, po =get_item (pn, ph->sid,eth_hdr (skb)->h_source, dev->ifindex);if (po)if (!schedule_work (&po->proto.pppoe.padt_work)) -sock_put (sk_pppox (po)); +sock_put (&po->sk); abort:kfree_skb (skb);
drivers/net/ppp/pptp.c +3 -3
@@ -62,7 +62,7 @@ static struct pppox_sock *lookup_chan(u16 call_id, __be32 s_addr)if (opt->dst_addr.sin_addr.s_addr != s_addr) sock =NULL ;else -sock_hold (sk_pppox (sock)); +sock_hold (&sock->sk); }rcu_read_unlock ();
@@ -164,7 +164,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)struct iphdr *iph;int max_headroom; -if (sk_pppox (po)->sk_state &PPPOX_DEAD ) +if (po->sk.sk_state &PPPOX_DEAD ) goto tx_drop; rt =pptp_route_output (po, &fl4);
@@ -375,7 +375,7 @@ static int pptp_rcv(struct sk_buff *skb)if (po) {skb_dst_drop (skb);nf_reset_ct (skb); -return sk_receive_skb (sk_pppox (po), skb,0 ); +return sk_receive_skb (&po->sk, skb,0 ); } drop:kfree_skb (skb);
include/linux/if_pppox.h +0 -5
@@ -57,11 +57,6 @@ static inline struct pppox_sock *pppox_sk(struct sock *sk)return (struct pppox_sock *)sk; } -static inline struct sock *sk_pppox (struct pppox_sock *po) -{ -return (struct sock *)po; -} -struct module ;struct pppox_proto {
Signature · 1 line
2.43.0
PATCH v2 2/2 pppox: convert pppox_sk() to use container_of()
Use container_of() macro instead of direct pointer casting to get the pppox_sock from a sock pointer.
---
Changes in v2:
Do not remove the comment, as the struct is allocated from sk_alloc and still require sock to be the first member.
Link to v1: https://lore.kernel.org/r/[email protected]
include/linux/if_pppox.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/if_pppox.h +1 -1
@@ -54,7 +54,7 @@ struct pppox_sock {static inline struct pppox_sock *pppox_sk (struct sock *sk) { -return (struct pppox_sock *)sk; + return container_of(sk, struct pppox_sock, sk); }struct module ;
Signature · 1 line
2.43.0
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Fri, 10 Apr 2026 13:49:49 +0800 you wrote:
The sk member can be directly accessed from struct
pppox_sockwithout relying on type casting. Remove thesk_pppox()helper and update all call sites to usepo->skdirectly.Signed-off-by Qingfang Deng <[email protected]>---
Changes in v2: none
Link to v1: https://lore.kernel.org/r/[email protected][...]
Here is the summary with links:
- [net-next,v2,1/2] pppox: remove sk_pppox() helper
https://git.kernel.org/netdev/net-next/c/105369d627b9 - [net-next,v2,2/2] pppox: convert pppox_sk() to use container_of() https://git.kernel.org/netdev/net-next/c/6bc78039a77a
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html