mirror of
https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9.git
synced 2026-09-09 00:08:12 +08:00
Merge: ppp: stable backport for 9.9 phase 2
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7958 JIRA: https://redhat.atlassian.net/browse/RHEL-152688 Upstream Status: linux.git PPP fixes for RHEL 9.9. Signed-off-by: Guillaume Nault <gnault@redhat.com> Approved-by: Antoine Tenart <atenart@redhat.com> Approved-by: Florian Westphal <fwestpha@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include <linux/ppp_channel.h>
|
||||
#include <linux/ppp-comp.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/rculist.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <linux/if_arp.h>
|
||||
#include <linux/ip.h>
|
||||
@@ -1613,11 +1614,14 @@ static int ppp_fill_forward_path(struct net_device_path_ctx *ctx,
|
||||
if (ppp->flags & SC_MULTILINK)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (list_empty(&ppp->channels))
|
||||
pch = list_first_or_null_rcu(&ppp->channels, struct channel, clist);
|
||||
if (!pch)
|
||||
return -ENODEV;
|
||||
|
||||
chan = READ_ONCE(pch->chan);
|
||||
if (!chan)
|
||||
return -ENODEV;
|
||||
|
||||
pch = list_first_entry(&ppp->channels, struct channel, clist);
|
||||
chan = pch->chan;
|
||||
if (!chan->ops->fill_forward_path)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
@@ -2998,7 +3002,7 @@ ppp_unregister_channel(struct ppp_channel *chan)
|
||||
*/
|
||||
down_write(&pch->chan_sem);
|
||||
spin_lock_bh(&pch->downl);
|
||||
pch->chan = NULL;
|
||||
WRITE_ONCE(pch->chan, NULL);
|
||||
spin_unlock_bh(&pch->downl);
|
||||
up_write(&pch->chan_sem);
|
||||
ppp_disconnect_channel(pch);
|
||||
@@ -3504,7 +3508,7 @@ ppp_connect_channel(struct channel *pch, int unit)
|
||||
hdrlen = pch->file.hdrlen + 2; /* for protocol bytes */
|
||||
if (hdrlen > ppp->dev->hard_header_len)
|
||||
ppp->dev->hard_header_len = hdrlen;
|
||||
list_add_tail(&pch->clist, &ppp->channels);
|
||||
list_add_tail_rcu(&pch->clist, &ppp->channels);
|
||||
++ppp->n_channels;
|
||||
pch->ppp = ppp;
|
||||
refcount_inc(&ppp->file.refcnt);
|
||||
@@ -3534,10 +3538,11 @@ ppp_disconnect_channel(struct channel *pch)
|
||||
if (ppp) {
|
||||
/* remove it from the ppp unit's list */
|
||||
ppp_lock(ppp);
|
||||
list_del(&pch->clist);
|
||||
list_del_rcu(&pch->clist);
|
||||
if (--ppp->n_channels == 0)
|
||||
wake_up_interruptible(&ppp->file.rwait);
|
||||
ppp_unlock(ppp);
|
||||
synchronize_net();
|
||||
if (refcount_dec_and_test(&ppp->file.refcnt))
|
||||
ppp_destroy_interface(ppp);
|
||||
err = 0;
|
||||
|
||||
+8
-17
@@ -130,22 +130,12 @@ static const struct ppp_channel_ops pppol2tp_chan_ops = {
|
||||
|
||||
static const struct proto_ops pppol2tp_ops;
|
||||
|
||||
/* Retrieves the pppol2tp socket associated to a session.
|
||||
* A reference is held on the returned socket, so this function must be paired
|
||||
* with sock_put().
|
||||
*/
|
||||
/* Retrieves the pppol2tp socket associated to a session. */
|
||||
static struct sock *pppol2tp_session_get_sock(struct l2tp_session *session)
|
||||
{
|
||||
struct pppol2tp_session *ps = l2tp_session_priv(session);
|
||||
struct sock *sk;
|
||||
|
||||
rcu_read_lock();
|
||||
sk = rcu_dereference(ps->sk);
|
||||
if (sk)
|
||||
sock_hold(sk);
|
||||
rcu_read_unlock();
|
||||
|
||||
return sk;
|
||||
return rcu_dereference(ps->sk);
|
||||
}
|
||||
|
||||
/* Helpers to obtain tunnel/session contexts from sockets.
|
||||
@@ -211,14 +201,13 @@ end:
|
||||
|
||||
static void pppol2tp_recv(struct l2tp_session *session, struct sk_buff *skb, int data_len)
|
||||
{
|
||||
struct pppol2tp_session *ps = l2tp_session_priv(session);
|
||||
struct sock *sk = NULL;
|
||||
struct sock *sk;
|
||||
|
||||
/* If the socket is bound, send it in to PPP's input queue. Otherwise
|
||||
* queue it on the session socket.
|
||||
*/
|
||||
rcu_read_lock();
|
||||
sk = rcu_dereference(ps->sk);
|
||||
sk = pppol2tp_session_get_sock(session);
|
||||
if (!sk)
|
||||
goto no_sock;
|
||||
|
||||
@@ -528,13 +517,14 @@ static void pppol2tp_show(struct seq_file *m, void *arg)
|
||||
struct l2tp_session *session = arg;
|
||||
struct sock *sk;
|
||||
|
||||
rcu_read_lock();
|
||||
sk = pppol2tp_session_get_sock(session);
|
||||
if (sk) {
|
||||
struct pppox_sock *po = pppox_sk(sk);
|
||||
|
||||
seq_printf(m, " interface %s\n", ppp_dev_name(&po->chan));
|
||||
sock_put(sk);
|
||||
}
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
static void pppol2tp_session_init(struct l2tp_session *session)
|
||||
@@ -1540,6 +1530,7 @@ static void pppol2tp_seq_session_show(struct seq_file *m, void *v)
|
||||
port = ntohs(inet->inet_sport);
|
||||
}
|
||||
|
||||
rcu_read_lock();
|
||||
sk = pppol2tp_session_get_sock(session);
|
||||
if (sk) {
|
||||
state = sk->sk_state;
|
||||
@@ -1575,8 +1566,8 @@ static void pppol2tp_seq_session_show(struct seq_file *m, void *v)
|
||||
struct pppox_sock *po = pppox_sk(sk);
|
||||
|
||||
seq_printf(m, " interface %s\n", ppp_dev_name(&po->chan));
|
||||
sock_put(sk);
|
||||
}
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
static int pppol2tp_seq_show(struct seq_file *m, void *v)
|
||||
|
||||
Reference in New Issue
Block a user