Thread (11 messages) flat view 11 messages, 5 authors, 2016-08-22

Re: [PATCH v3 net-next] l2tp: Refactor the codes with existing macros instead of literal number

From: Guillaume Nault <hidden>
Date: 2016-08-22 09:54:32

On Mon, Aug 22, 2016 at 08:13:48AM +0800, Feng Gao wrote:
inline

On Mon, Aug 22, 2016 at 6:36 AM, Philp Prindeville
[off-list ref] wrote:
quoted
Inline


On 08/20/2016 09:52 AM, fgao@48lvckh6395k16k5.yundunddos.com wrote:
quoted
From: Gao Feng <redacted>

Use PPP_ALLSTATIONS, PPP_UI, and SEND_SHUTDOWN instead of 0xff,
0x03, and 2 separately.

Signed-off-by: Gao Feng <redacted>
---
  v3: Modify the subject;
  v2: Only replace the literal number with macros according to Guillaume's
advice
  v1: Inital patch

  net/l2tp/l2tp_ppp.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index d9560aa..65e2fd6 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -177,7 +177,7 @@ static int pppol2tp_recv_payload_hook(struct sk_buff
*skb)
        if (!pskb_may_pull(skb, 2))
                return 1;
  -     if ((skb->data[0] == 0xff) && (skb->data[1] == 0x03))
+       if ((skb->data[0] == PPP_ALLSTATIONS) && (skb->data[1] == PPP_UI))

This should have used PPP_ADDRESS() and PPP_CONTROL() here.
In my initial patch, I replace them with PPP_ADDRESS() and PPP_CONTROL.
But Guillaume thought it was not clear as before.
So I revert it.
quoted
quoted
                skb_pull(skb, 2);

This magic number should go away.
Same as above.
quoted
quoted
        return 0;
@@ -282,7 +282,7 @@ static void pppol2tp_session_sock_put(struct
l2tp_session *session)
  static int pppol2tp_sendmsg(struct socket *sock, struct msghdr *m,
                            size_t total_len)
  {
-       static const unsigned char ppph[2] = { 0xff, 0x03 };
+       static const unsigned char ppph[2] = {PPP_ALLSTATIONS, PPP_UI};

PPP has a 4-byte header.  Where's the protocol value?
In the original code, I fail to find the code which is used to fill
the protocol value.
So I keep the two bytes header. And I thought the protocol value may be filled
by the upper layer.
And you were right. This was a macro replacement patch anyway, so you
didn't have to bring functional changes with it.
And if the protocol field was really missing, the L2TP module would
have never worked.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help