mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-27 17:35:18 -04:00
bpf: Allow IP_TRANSPARENT and IPV6_TRANSPARENT in bpf_{set,get}sockopt()
Currently, bpf_setsockopt() and bpf_getsockopt() for SOL_IP and SOL_IPV6 only allow a small subset of socket options (such as IP_TOS, IPV6_TCLASS, and IPV6_AUTOFLOWLABEL). Calling bpf_setsockopt() with IP_TRANSPARENT or IPV6_TRANSPARENT fails with -EINVAL. Transparent proxying (TPROXY) and related networking components often rely on IP_TRANSPARENT and IPV6_TRANSPARENT to enable binding sockets to non-local IP addresses. Allow IP_TRANSPARENT for SOL_IP in sol_ip_sockopt() and IPV6_TRANSPARENT for SOL_IPV6 in sol_ipv6_sockopt(). Signed-off-by: Shivaji Kant <shivajikant@google.com> Tested-by: Anubhav Singh <anubhavsinggh@google.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://lore.kernel.org/bpf/20260801051307.478469-1-shivajikant@google.com Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
This commit is contained in:
committed by
Kumar Kartikeya Dwivedi
parent
0b10b94547
commit
dec58a70d4
@@ -5645,6 +5645,7 @@ static int sol_ip_sockopt(struct sock *sk, int optname,
|
||||
|
||||
switch (optname) {
|
||||
case IP_TOS:
|
||||
case IP_TRANSPARENT:
|
||||
if (*optlen != sizeof(int))
|
||||
return -EINVAL;
|
||||
break;
|
||||
@@ -5671,6 +5672,7 @@ static int sol_ipv6_sockopt(struct sock *sk, int optname,
|
||||
switch (optname) {
|
||||
case IPV6_TCLASS:
|
||||
case IPV6_AUTOFLOWLABEL:
|
||||
case IPV6_TRANSPARENT:
|
||||
if (*optlen != sizeof(int))
|
||||
return -EINVAL;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user