l2tp_ip6.c (b71a61ccfebb4ff733d2d9fc66cd5c75b7ae46a2) l2tp_ip6.c (20dcb1107ab1a3423c72a88269b9775cc549262a)
1// SPDX-License-Identifier: GPL-2.0-or-later
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * L2TPv3 IP encapsulation support for IPv6
2/* L2TPv3 IP encapsulation support for IPv6
4 *
5 * Copyright (c) 2012 Katalix Systems Ltd
6 */
7
8#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
9
10#include <linux/icmp.h>
11#include <linux/module.h>

--- 21 unchanged lines hidden (view full) ---

33struct l2tp_ip6_sock {
34 /* inet_sock has to be the first member of l2tp_ip6_sock */
35 struct inet_sock inet;
36
37 u32 conn_id;
38 u32 peer_conn_id;
39
40 /* ipv6_pinfo has to be the last member of l2tp_ip6_sock, see
3 *
4 * Copyright (c) 2012 Katalix Systems Ltd
5 */
6
7#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
8
9#include <linux/icmp.h>
10#include <linux/module.h>

--- 21 unchanged lines hidden (view full) ---

32struct l2tp_ip6_sock {
33 /* inet_sock has to be the first member of l2tp_ip6_sock */
34 struct inet_sock inet;
35
36 u32 conn_id;
37 u32 peer_conn_id;
38
39 /* ipv6_pinfo has to be the last member of l2tp_ip6_sock, see
41 inet6_sk_generic */
40 * inet6_sk_generic
41 */
42 struct ipv6_pinfo inet6;
43};
44
45static DEFINE_RWLOCK(l2tp_ip6_lock);
46static struct hlist_head l2tp_ip6_table;
47static struct hlist_head l2tp_ip6_bind_table;
48
49static inline struct l2tp_ip6_sock *l2tp_ip6_sk(const struct sock *sk)

--- 464 unchanged lines hidden (view full) ---

514 struct flowi6 fl6;
515 struct ipcm6_cookie ipc6;
516 int addr_len = msg->msg_namelen;
517 int transhdrlen = 4; /* zero session-id */
518 int ulen = len + transhdrlen;
519 int err;
520
521 /* Rough check on arithmetic overflow,
42 struct ipv6_pinfo inet6;
43};
44
45static DEFINE_RWLOCK(l2tp_ip6_lock);
46static struct hlist_head l2tp_ip6_table;
47static struct hlist_head l2tp_ip6_bind_table;
48
49static inline struct l2tp_ip6_sock *l2tp_ip6_sk(const struct sock *sk)

--- 464 unchanged lines hidden (view full) ---

514 struct flowi6 fl6;
515 struct ipcm6_cookie ipc6;
516 int addr_len = msg->msg_namelen;
517 int transhdrlen = 4; /* zero session-id */
518 int ulen = len + transhdrlen;
519 int err;
520
521 /* Rough check on arithmetic overflow,
522 better check is made in ip6_append_data().
522 * better check is made in ip6_append_data().
523 */
524 if (len > INT_MAX)
525 return -EMSGSIZE;
526
527 /* Mirror BSD error message compatibility */
528 if (msg->msg_flags & MSG_OOB)
529 return -EOPNOTSUPP;
530
523 */
524 if (len > INT_MAX)
525 return -EMSGSIZE;
526
527 /* Mirror BSD error message compatibility */
528 if (msg->msg_flags & MSG_OOB)
529 return -EOPNOTSUPP;
530
531 /*
532 * Get and verify the address.
533 */
531 /* Get and verify the address */
534 memset(&fl6, 0, sizeof(fl6));
535
536 fl6.flowi6_mark = sk->sk_mark;
537 fl6.flowi6_uid = sk->sk_uid;
538
539 ipcm6_init(&ipc6);
540
541 if (lsa) {

--- 8 unchanged lines hidden (view full) ---

550 fl6.flowlabel = lsa->l2tp_flowinfo & IPV6_FLOWINFO_MASK;
551 if (fl6.flowlabel & IPV6_FLOWLABEL_MASK) {
552 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
553 if (IS_ERR(flowlabel))
554 return -EINVAL;
555 }
556 }
557
532 memset(&fl6, 0, sizeof(fl6));
533
534 fl6.flowi6_mark = sk->sk_mark;
535 fl6.flowi6_uid = sk->sk_uid;
536
537 ipcm6_init(&ipc6);
538
539 if (lsa) {

--- 8 unchanged lines hidden (view full) ---

548 fl6.flowlabel = lsa->l2tp_flowinfo & IPV6_FLOWINFO_MASK;
549 if (fl6.flowlabel & IPV6_FLOWLABEL_MASK) {
550 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
551 if (IS_ERR(flowlabel))
552 return -EINVAL;
553 }
554 }
555
558 /*
559 * Otherwise it will be difficult to maintain
556 /* Otherwise it will be difficult to maintain
560 * sk->sk_dst_cache.
561 */
562 if (sk->sk_state == TCP_ESTABLISHED &&
563 ipv6_addr_equal(daddr, &sk->sk_v6_daddr))
564 daddr = &sk->sk_v6_daddr;
565
566 if (addr_len >= sizeof(struct sockaddr_in6) &&
567 lsa->l2tp_scope_id &&

--- 261 unchanged lines hidden ---
557 * sk->sk_dst_cache.
558 */
559 if (sk->sk_state == TCP_ESTABLISHED &&
560 ipv6_addr_equal(daddr, &sk->sk_v6_daddr))
561 daddr = &sk->sk_v6_daddr;
562
563 if (addr_len >= sizeof(struct sockaddr_in6) &&
564 lsa->l2tp_scope_id &&

--- 261 unchanged lines hidden ---