1
0

081-01-pppoe-Use-workqueue-to-die-properly-when-a-PADT-is-r.patch 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. From: Simon Farnsworth <simon@farnz.org.uk>
  2. Date: Sun, 1 Mar 2015 10:54:39 +0000
  3. Subject: [PATCH] pppoe: Use workqueue to die properly when a PADT is received
  4. When a PADT frame is received, the socket may not be in a good state to
  5. close down the PPP interface. The current implementation handles this by
  6. simply blocking all further PPP traffic, and hoping that the lack of traffic
  7. will trigger the user to investigate.
  8. Use schedule_work to get to a process context from which we clear down the
  9. PPP interface, in a fashion analogous to hangup on a TTY-based PPP
  10. interface. This causes pppd to disconnect immediately, and allows tools to
  11. take immediate corrective action.
  12. Note that pppd's rp_pppoe.so plugin has code in it to disable the session
  13. when it disconnects; however, as a consequence of this patch, the session is
  14. already disabled before rp_pppoe.so is asked to disable the session. The
  15. result is a harmless error message:
  16. Failed to disconnect PPPoE socket: 114 Operation already in progress
  17. This message is safe to ignore, as long as the error is 114 Operation
  18. already in progress; in that specific case, it means that the PPPoE session
  19. has already been disabled before pppd tried to disable it.
  20. Signed-off-by: Simon Farnsworth <simon@farnz.org.uk>
  21. Tested-by: Dan Williams <dcbw@redhat.com>
  22. Tested-by: Christoph Schulz <develop@kristov.de>
  23. Signed-off-by: David S. Miller <davem@davemloft.net>
  24. ---
  25. --- a/drivers/net/ppp/pppoe.c
  26. +++ b/drivers/net/ppp/pppoe.c
  27. @@ -454,6 +454,18 @@ out:
  28. return NET_RX_DROP;
  29. }
  30. +static void pppoe_unbind_sock_work(struct work_struct *work)
  31. +{
  32. + struct pppox_sock *po = container_of(work, struct pppox_sock,
  33. + proto.pppoe.padt_work);
  34. + struct sock *sk = sk_pppox(po);
  35. +
  36. + lock_sock(sk);
  37. + pppox_unbind_sock(sk);
  38. + release_sock(sk);
  39. + sock_put(sk);
  40. +}
  41. +
  42. /************************************************************************
  43. *
  44. * Receive a PPPoE Discovery frame.
  45. @@ -499,7 +511,8 @@ static int pppoe_disc_rcv(struct sk_buff
  46. }
  47. bh_unlock_sock(sk);
  48. - sock_put(sk);
  49. + if (!schedule_work(&po->proto.pppoe.padt_work))
  50. + sock_put(sk);
  51. }
  52. abort:
  53. @@ -612,6 +625,8 @@ static int pppoe_connect(struct socket *
  54. lock_sock(sk);
  55. + INIT_WORK(&po->proto.pppoe.padt_work, pppoe_unbind_sock_work);
  56. +
  57. error = -EINVAL;
  58. if (sockaddr_len != sizeof(struct sockaddr_pppox))
  59. --- a/include/linux/if_pppox.h
  60. +++ b/include/linux/if_pppox.h
  61. @@ -19,6 +19,7 @@
  62. #include <linux/netdevice.h>
  63. #include <linux/ppp_channel.h>
  64. #include <linux/skbuff.h>
  65. +#include <linux/workqueue.h>
  66. #include <uapi/linux/if_pppox.h>
  67. static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb)
  68. @@ -32,6 +33,7 @@ struct pppoe_opt {
  69. struct pppoe_addr pa; /* what this socket is bound to*/
  70. struct sockaddr_pppox relay; /* what socket data will be
  71. relayed to (PPPoE relaying) */
  72. + struct work_struct padt_work;/* Work item for handling PADT */
  73. };
  74. struct pptp_opt {