Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Qingfang Deng <qingfang.deng@linux.dev>
Link: https://patch.msgid.link/20260410054954.114031-1-qingfang.deng@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Qingfang Deng and committed by
Jakub Kicinski
105369d6 f05b619d

+8 -13
+5 -5
drivers/net/ppp/pppoe.c
··· 231 231 struct pppox_sock *po; 232 232 233 233 po = __get_item(pn, sid, addr, ifindex); 234 - if (po && !refcount_inc_not_zero(&sk_pppox(po)->sk_refcnt)) 234 + if (po && !refcount_inc_not_zero(&po->sk.sk_refcnt)) 235 235 po = NULL; 236 236 237 237 return po; ··· 273 273 if (!po) 274 274 break; 275 275 276 - sk = sk_pppox(po); 276 + sk = &po->sk; 277 277 278 278 /* We always grab the socket lock, followed by the 279 279 * hash_lock, in that order. Since we should hold the ··· 413 413 if (!po) 414 414 goto drop; 415 415 416 - return __sk_receive_skb(sk_pppox(po), skb, 0, 1, false); 416 + return __sk_receive_skb(&po->sk, skb, 0, 1, false); 417 417 418 418 drop: 419 419 kfree_skb(skb); ··· 425 425 { 426 426 struct pppox_sock *po = container_of(work, struct pppox_sock, 427 427 proto.pppoe.padt_work); 428 - struct sock *sk = sk_pppox(po); 428 + struct sock *sk = &po->sk; 429 429 430 430 lock_sock(sk); 431 431 if (po->pppoe_dev) { ··· 469 469 po = get_item(pn, ph->sid, eth_hdr(skb)->h_source, dev->ifindex); 470 470 if (po) 471 471 if (!schedule_work(&po->proto.pppoe.padt_work)) 472 - sock_put(sk_pppox(po)); 472 + sock_put(&po->sk); 473 473 474 474 abort: 475 475 kfree_skb(skb);
+3 -3
drivers/net/ppp/pptp.c
··· 62 62 if (opt->dst_addr.sin_addr.s_addr != s_addr) 63 63 sock = NULL; 64 64 else 65 - sock_hold(sk_pppox(sock)); 65 + sock_hold(&sock->sk); 66 66 } 67 67 rcu_read_unlock(); 68 68 ··· 164 164 struct iphdr *iph; 165 165 int max_headroom; 166 166 167 - if (sk_pppox(po)->sk_state & PPPOX_DEAD) 167 + if (po->sk.sk_state & PPPOX_DEAD) 168 168 goto tx_drop; 169 169 170 170 rt = pptp_route_output(po, &fl4); ··· 375 375 if (po) { 376 376 skb_dst_drop(skb); 377 377 nf_reset_ct(skb); 378 - return sk_receive_skb(sk_pppox(po), skb, 0); 378 + return sk_receive_skb(&po->sk, skb, 0); 379 379 } 380 380 drop: 381 381 kfree_skb(skb);
-5
include/linux/if_pppox.h
··· 57 57 return (struct pppox_sock *)sk; 58 58 } 59 59 60 - static inline struct sock *sk_pppox(struct pppox_sock *po) 61 - { 62 - return (struct sock *)po; 63 - } 64 - 65 60 struct module; 66 61 67 62 struct pppox_proto {