Skip to content

Commit 032234d

Browse files
dsaherndavem330
authored andcommitted
net/ipv6: Make __inet6_bind static
BPF core gets access to __inet6_bind via ipv6_bpf_stub_impl, so it is not invoked directly outside of af_inet6.c. Make it static and move inet6_bind after to avoid forward declaration. Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 684009d commit 032234d

File tree

2 files changed

+26
-29
lines changed

2 files changed

+26
-29
lines changed

include/net/ipv6.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,8 +1044,6 @@ void ipv6_local_error(struct sock *sk, int err, struct flowi6 *fl6, u32 info);
10441044
void ipv6_local_rxpmtu(struct sock *sk, struct flowi6 *fl6, u32 mtu);
10451045

10461046
int inet6_release(struct socket *sock);
1047-
int __inet6_bind(struct sock *sock, struct sockaddr *uaddr, int addr_len,
1048-
bool force_bind_address_no_port, bool with_lock);
10491047
int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len);
10501048
int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
10511049
int peer);

net/ipv6/af_inet6.c

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -273,33 +273,8 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol,
273273
goto out;
274274
}
275275

276-
277-
/* bind for INET6 API */
278-
int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
279-
{
280-
struct sock *sk = sock->sk;
281-
int err = 0;
282-
283-
/* If the socket has its own bind function then use it. */
284-
if (sk->sk_prot->bind)
285-
return sk->sk_prot->bind(sk, uaddr, addr_len);
286-
287-
if (addr_len < SIN6_LEN_RFC2133)
288-
return -EINVAL;
289-
290-
/* BPF prog is run before any checks are done so that if the prog
291-
* changes context in a wrong way it will be caught.
292-
*/
293-
err = BPF_CGROUP_RUN_PROG_INET6_BIND(sk, uaddr);
294-
if (err)
295-
return err;
296-
297-
return __inet6_bind(sk, uaddr, addr_len, false, true);
298-
}
299-
EXPORT_SYMBOL(inet6_bind);
300-
301-
int __inet6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len,
302-
bool force_bind_address_no_port, bool with_lock)
276+
static int __inet6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len,
277+
bool force_bind_address_no_port, bool with_lock)
303278
{
304279
struct sockaddr_in6 *addr = (struct sockaddr_in6 *)uaddr;
305280
struct inet_sock *inet = inet_sk(sk);
@@ -444,6 +419,30 @@ int __inet6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len,
444419
goto out;
445420
}
446421

422+
/* bind for INET6 API */
423+
int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
424+
{
425+
struct sock *sk = sock->sk;
426+
int err = 0;
427+
428+
/* If the socket has its own bind function then use it. */
429+
if (sk->sk_prot->bind)
430+
return sk->sk_prot->bind(sk, uaddr, addr_len);
431+
432+
if (addr_len < SIN6_LEN_RFC2133)
433+
return -EINVAL;
434+
435+
/* BPF prog is run before any checks are done so that if the prog
436+
* changes context in a wrong way it will be caught.
437+
*/
438+
err = BPF_CGROUP_RUN_PROG_INET6_BIND(sk, uaddr);
439+
if (err)
440+
return err;
441+
442+
return __inet6_bind(sk, uaddr, addr_len, false, true);
443+
}
444+
EXPORT_SYMBOL(inet6_bind);
445+
447446
int inet6_release(struct socket *sock)
448447
{
449448
struct sock *sk = sock->sk;

0 commit comments

Comments
 (0)