protocol.c (74c12ee02af109adcde36ec184fa59c0afb0edaa) | protocol.c (b6e4a1aeeb14cad595f70b31cc376903d322c821) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* Multipath TCP 3 * 4 * Copyright (c) 2017 - 2019, Intel Corporation. 5 */ 6 7#define pr_fmt(fmt) "MPTCP: " fmt 8 --- 629 unchanged lines hidden (view full) --- 638static struct ipv6_pinfo *mptcp_inet6_sk(const struct sock *sk) 639{ 640 unsigned int offset = sizeof(struct mptcp6_sock) - sizeof(struct ipv6_pinfo); 641 642 return (struct ipv6_pinfo *)(((u8 *)sk) + offset); 643} 644#endif 645 | 1// SPDX-License-Identifier: GPL-2.0 2/* Multipath TCP 3 * 4 * Copyright (c) 2017 - 2019, Intel Corporation. 5 */ 6 7#define pr_fmt(fmt) "MPTCP: " fmt 8 --- 629 unchanged lines hidden (view full) --- 638static struct ipv6_pinfo *mptcp_inet6_sk(const struct sock *sk) 639{ 640 unsigned int offset = sizeof(struct mptcp6_sock) - sizeof(struct ipv6_pinfo); 641 642 return (struct ipv6_pinfo *)(((u8 *)sk) + offset); 643} 644#endif 645 |
646struct sock *mptcp_sk_clone_lock(const struct sock *sk) | 646static struct sock *mptcp_sk_clone_lock(const struct sock *sk) |
647{ 648 struct sock *nsk = sk_clone_lock(sk, GFP_ATOMIC); 649 650 if (!nsk) 651 return NULL; 652 653#if IS_ENABLED(CONFIG_MPTCP_IPV6) 654 if (nsk->sk_family == AF_INET6) --- 95 unchanged lines hidden (view full) --- 750 if (msk->cached_ext) 751 __skb_ext_put(msk->cached_ext); 752} 753 754static int mptcp_setsockopt(struct sock *sk, int level, int optname, 755 char __user *optval, unsigned int optlen) 756{ 757 struct mptcp_sock *msk = mptcp_sk(sk); | 647{ 648 struct sock *nsk = sk_clone_lock(sk, GFP_ATOMIC); 649 650 if (!nsk) 651 return NULL; 652 653#if IS_ENABLED(CONFIG_MPTCP_IPV6) 654 if (nsk->sk_family == AF_INET6) --- 95 unchanged lines hidden (view full) --- 750 if (msk->cached_ext) 751 __skb_ext_put(msk->cached_ext); 752} 753 754static int mptcp_setsockopt(struct sock *sk, int level, int optname, 755 char __user *optval, unsigned int optlen) 756{ 757 struct mptcp_sock *msk = mptcp_sk(sk); |
758 int ret = -EOPNOTSUPP; | |
759 struct socket *ssock; | 758 struct socket *ssock; |
760 struct sock *ssk; | |
761 762 pr_debug("msk=%p", msk); 763 764 /* @@ the meaning of setsockopt() when the socket is connected and | 759 760 pr_debug("msk=%p", msk); 761 762 /* @@ the meaning of setsockopt() when the socket is connected and |
765 * there are multiple subflows is not defined. | 763 * there are multiple subflows is not yet defined. It is up to the 764 * MPTCP-level socket to configure the subflows until the subflow 765 * is in TCP fallback, when TCP socket options are passed through 766 * to the one remaining subflow. |
766 */ 767 lock_sock(sk); | 767 */ 768 lock_sock(sk); |
768 ssock = __mptcp_socket_create(msk, MPTCP_SAME_STATE); 769 if (IS_ERR(ssock)) { 770 release_sock(sk); 771 return ret; 772 } | 769 ssock = __mptcp_tcp_fallback(msk); 770 if (ssock) 771 return tcp_setsockopt(ssock->sk, level, optname, optval, 772 optlen); |
773 | 773 |
774 ssk = ssock->sk; 775 sock_hold(ssk); | |
776 release_sock(sk); 777 | 774 release_sock(sk); 775 |
778 ret = tcp_setsockopt(ssk, level, optname, optval, optlen); 779 sock_put(ssk); 780 781 return ret; | 776 return -EOPNOTSUPP; |
782} 783 784static int mptcp_getsockopt(struct sock *sk, int level, int optname, 785 char __user *optval, int __user *option) 786{ 787 struct mptcp_sock *msk = mptcp_sk(sk); | 777} 778 779static int mptcp_getsockopt(struct sock *sk, int level, int optname, 780 char __user *optval, int __user *option) 781{ 782 struct mptcp_sock *msk = mptcp_sk(sk); |
788 int ret = -EOPNOTSUPP; | |
789 struct socket *ssock; | 783 struct socket *ssock; |
790 struct sock *ssk; | |
791 792 pr_debug("msk=%p", msk); 793 | 784 785 pr_debug("msk=%p", msk); 786 |
794 /* @@ the meaning of getsockopt() when the socket is connected and 795 * there are multiple subflows is not defined. | 787 /* @@ the meaning of setsockopt() when the socket is connected and 788 * there are multiple subflows is not yet defined. It is up to the 789 * MPTCP-level socket to configure the subflows until the subflow 790 * is in TCP fallback, when socket options are passed through 791 * to the one remaining subflow. |
796 */ 797 lock_sock(sk); | 792 */ 793 lock_sock(sk); |
798 ssock = __mptcp_socket_create(msk, MPTCP_SAME_STATE); 799 if (IS_ERR(ssock)) { 800 release_sock(sk); 801 return ret; 802 } | 794 ssock = __mptcp_tcp_fallback(msk); 795 if (ssock) 796 return tcp_getsockopt(ssock->sk, level, optname, optval, 797 option); |
803 | 798 |
804 ssk = ssock->sk; 805 sock_hold(ssk); | |
806 release_sock(sk); 807 | 799 release_sock(sk); 800 |
808 ret = tcp_getsockopt(ssk, level, optname, optval, option); 809 sock_put(ssk); 810 811 return ret; | 801 return -EOPNOTSUPP; |
812} 813 814static int mptcp_get_port(struct sock *sk, unsigned short snum) 815{ 816 struct mptcp_sock *msk = mptcp_sk(sk); 817 struct socket *ssock; 818 819 ssock = __mptcp_nmpc_socket(msk); --- 433 unchanged lines hidden --- | 802} 803 804static int mptcp_get_port(struct sock *sk, unsigned short snum) 805{ 806 struct mptcp_sock *msk = mptcp_sk(sk); 807 struct socket *ssock; 808 809 ssock = __mptcp_nmpc_socket(msk); --- 433 unchanged lines hidden --- |