]> git.baikalelectronics.ru Git - kernel.git/commitdiff
l2tp: use standard API for warning log messages
authorTom Parkin <tparkin@katalix.com>
Sat, 22 Aug 2020 14:59:03 +0000 (15:59 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sat, 22 Aug 2020 19:44:37 +0000 (12:44 -0700)
The l2tp_* log wrappers only emit messages of a given category if the
tunnel or session structure has the appropriate flag set in its debug
field.  Flags default to being unset.

For warning messages, this doesn't make a lot of sense since an
administrator is likely to want to know about datapath warnings without
needing to tweak the debug flags setting for a given tunnel or session
instance.

Modify l2tp_warn callsites to use pr_warn_ratelimited instead for
unconditional output of warning messages.

Signed-off-by: Tom Parkin <tparkin@katalix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/l2tp/l2tp_core.c
net/l2tp/l2tp_ppp.c

index a3017c46f653116d3cc5c6ed5a31a473363e06e1..54f46ed97b3d49f1ff69afa81b1dbc0a483e67d2 100644 (file)
@@ -665,10 +665,9 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
        /* Parse and check optional cookie */
        if (session->peer_cookie_len > 0) {
                if (memcmp(ptr, &session->peer_cookie[0], session->peer_cookie_len)) {
-                       l2tp_warn(tunnel, L2TP_MSG_DATA,
-                                 "%s: cookie mismatch (%u/%u). Discarding.\n",
-                                 tunnel->name, tunnel->tunnel_id,
-                                 session->session_id);
+                       pr_warn_ratelimited("%s: cookie mismatch (%u/%u). Discarding.\n",
+                                           tunnel->name, tunnel->tunnel_id,
+                                           session->session_id);
                        atomic_long_inc(&session->stats.rx_cookie_discards);
                        goto discard;
                }
@@ -721,9 +720,8 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
                 * If user has configured mandatory sequence numbers, discard.
                 */
                if (session->recv_seq) {
-                       l2tp_warn(session, L2TP_MSG_SEQ,
-                                 "%s: recv data has no seq numbers when required. Discarding.\n",
-                                 session->name);
+                       pr_warn_ratelimited("%s: recv data has no seq numbers when required. Discarding.\n",
+                                           session->name);
                        atomic_long_inc(&session->stats.rx_seq_discards);
                        goto discard;
                }
@@ -740,9 +738,8 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
                        session->send_seq = 0;
                        l2tp_session_set_header_len(session, tunnel->version);
                } else if (session->send_seq) {
-                       l2tp_warn(session, L2TP_MSG_SEQ,
-                                 "%s: recv data has no seq numbers when required. Discarding.\n",
-                                 session->name);
+                       pr_warn_ratelimited("%s: recv data has no seq numbers when required. Discarding.\n",
+                                           session->name);
                        atomic_long_inc(&session->stats.rx_seq_discards);
                        goto discard;
                }
@@ -835,9 +832,8 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb)
 
        /* Short packet? */
        if (!pskb_may_pull(skb, L2TP_HDR_SIZE_MAX)) {
-               l2tp_warn(tunnel, L2TP_MSG_DATA,
-                         "%s: recv short packet (len=%d)\n",
-                         tunnel->name, skb->len);
+               pr_warn_ratelimited("%s: recv short packet (len=%d)\n",
+                                   tunnel->name, skb->len);
                goto error;
        }
 
@@ -851,9 +847,8 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb)
        /* Check protocol version */
        version = hdrflags & L2TP_HDR_VER_MASK;
        if (version != tunnel->version) {
-               l2tp_warn(tunnel, L2TP_MSG_DATA,
-                         "%s: recv protocol version mismatch: got %d expected %d\n",
-                         tunnel->name, version, tunnel->version);
+               pr_warn_ratelimited("%s: recv protocol version mismatch: got %d expected %d\n",
+                                   tunnel->name, version, tunnel->version);
                goto error;
        }
 
@@ -891,9 +886,8 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb)
                        l2tp_session_dec_refcount(session);
 
                /* Not found? Pass to userspace to deal with */
-               l2tp_warn(tunnel, L2TP_MSG_DATA,
-                         "%s: no session found (%u/%u). Passing up.\n",
-                         tunnel->name, tunnel_id, session_id);
+               pr_warn_ratelimited("%s: no session found (%u/%u). Passing up.\n",
+                                   tunnel->name, tunnel_id, session_id);
                goto error;
        }
 
index 660ea95e09108eda72fb72e26d762ddf62a45f56..bd6bb17dfadbb1726fbf11de399f1069f126575f 100644 (file)
@@ -251,7 +251,7 @@ static void pppol2tp_recv(struct l2tp_session *session, struct sk_buff *skb, int
 
 no_sock:
        rcu_read_unlock();
-       l2tp_warn(session, L2TP_MSG_DATA, "%s: no socket\n", session->name);
+       pr_warn_ratelimited("%s: no socket in recv\n", session->name);
        kfree_skb(skb);
 }