Skip to content

Commit

Permalink
pppoe: Use workqueue to die properly when a PADT is received
Browse files Browse the repository at this point in the history
When a PADT frame is received, the socket may not be in a good state to
close down the PPP interface. The current implementation handles this by
simply blocking all further PPP traffic, and hoping that the lack of traffic
will trigger the user to investigate.

Use schedule_work to get to a process context from which we clear down the
PPP interface, in a fashion analogous to hangup on a TTY-based PPP
interface. This causes pppd to disconnect immediately, and allows tools to
take immediate corrective action.

Note that pppd's rp_pppoe.so plugin has code in it to disable the session
when it disconnects; however, as a consequence of this patch, the session is
already disabled before rp_pppoe.so is asked to disable the session. The
result is a harmless error message:

Failed to disconnect PPPoE socket: 114 Operation already in progress

This message is safe to ignore, as long as the error is 114 Operation
already in progress; in that specific case, it means that the PPPoE session
has already been disabled before pppd tried to disable it.

Signed-off-by: Simon Farnsworth <[email protected]>
Tested-by: Dan Williams <[email protected]>
Tested-by: Christoph Schulz <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
farnz authored and davem330 committed Mar 2, 2015
1 parent 26caa34 commit 287f3a9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 16 additions & 1 deletion drivers/net/ppp/pppoe.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,18 @@ static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev,
return NET_RX_DROP;
}

static void pppoe_unbind_sock_work(struct work_struct *work)
{
struct pppox_sock *po = container_of(work, struct pppox_sock,
proto.pppoe.padt_work);
struct sock *sk = sk_pppox(po);

lock_sock(sk);
pppox_unbind_sock(sk);
release_sock(sk);
sock_put(sk);
}

/************************************************************************
*
* Receive a PPPoE Discovery frame.
Expand Down Expand Up @@ -500,7 +512,8 @@ static int pppoe_disc_rcv(struct sk_buff *skb, struct net_device *dev,
}

bh_unlock_sock(sk);
sock_put(sk);
if (!schedule_work(&po->proto.pppoe.padt_work))
sock_put(sk);
}

abort:
Expand Down Expand Up @@ -613,6 +626,8 @@ static int pppoe_connect(struct socket *sock, struct sockaddr *uservaddr,

lock_sock(sk);

INIT_WORK(&po->proto.pppoe.padt_work, pppoe_unbind_sock_work);

error = -EINVAL;
if (sp->sa_protocol != PX_PROTO_OE)
goto end;
Expand Down
2 changes: 2 additions & 0 deletions include/linux/if_pppox.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <linux/netdevice.h>
#include <linux/ppp_channel.h>
#include <linux/skbuff.h>
#include <linux/workqueue.h>
#include <uapi/linux/if_pppox.h>

static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb)
Expand All @@ -32,6 +33,7 @@ struct pppoe_opt {
struct pppoe_addr pa; /* what this socket is bound to*/
struct sockaddr_pppox relay; /* what socket data will be
relayed to (PPPoE relaying) */
struct work_struct padt_work;/* Work item for handling PADT */
};

struct pptp_opt {
Expand Down

0 comments on commit 287f3a9

Please sign in to comment.