Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

l2tp: use standard API for warning log messages

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>

authored by

Tom Parkin and committed by
David S. Miller
5ee759cd ab141e37

+14 -20
+13 -19
net/l2tp/l2tp_core.c
··· 665 665 /* Parse and check optional cookie */ 666 666 if (session->peer_cookie_len > 0) { 667 667 if (memcmp(ptr, &session->peer_cookie[0], session->peer_cookie_len)) { 668 - l2tp_warn(tunnel, L2TP_MSG_DATA, 669 - "%s: cookie mismatch (%u/%u). Discarding.\n", 670 - tunnel->name, tunnel->tunnel_id, 671 - session->session_id); 668 + pr_warn_ratelimited("%s: cookie mismatch (%u/%u). Discarding.\n", 669 + tunnel->name, tunnel->tunnel_id, 670 + session->session_id); 672 671 atomic_long_inc(&session->stats.rx_cookie_discards); 673 672 goto discard; 674 673 } ··· 720 721 * If user has configured mandatory sequence numbers, discard. 721 722 */ 722 723 if (session->recv_seq) { 723 - l2tp_warn(session, L2TP_MSG_SEQ, 724 - "%s: recv data has no seq numbers when required. Discarding.\n", 725 - session->name); 724 + pr_warn_ratelimited("%s: recv data has no seq numbers when required. Discarding.\n", 725 + session->name); 726 726 atomic_long_inc(&session->stats.rx_seq_discards); 727 727 goto discard; 728 728 } ··· 738 740 session->send_seq = 0; 739 741 l2tp_session_set_header_len(session, tunnel->version); 740 742 } else if (session->send_seq) { 741 - l2tp_warn(session, L2TP_MSG_SEQ, 742 - "%s: recv data has no seq numbers when required. Discarding.\n", 743 - session->name); 743 + pr_warn_ratelimited("%s: recv data has no seq numbers when required. Discarding.\n", 744 + session->name); 744 745 atomic_long_inc(&session->stats.rx_seq_discards); 745 746 goto discard; 746 747 } ··· 832 835 833 836 /* Short packet? */ 834 837 if (!pskb_may_pull(skb, L2TP_HDR_SIZE_MAX)) { 835 - l2tp_warn(tunnel, L2TP_MSG_DATA, 836 - "%s: recv short packet (len=%d)\n", 837 - tunnel->name, skb->len); 838 + pr_warn_ratelimited("%s: recv short packet (len=%d)\n", 839 + tunnel->name, skb->len); 838 840 goto error; 839 841 } 840 842 ··· 847 851 /* Check protocol version */ 848 852 version = hdrflags & L2TP_HDR_VER_MASK; 849 853 if (version != tunnel->version) { 850 - l2tp_warn(tunnel, L2TP_MSG_DATA, 851 - "%s: recv protocol version mismatch: got %d expected %d\n", 852 - tunnel->name, version, tunnel->version); 854 + pr_warn_ratelimited("%s: recv protocol version mismatch: got %d expected %d\n", 855 + tunnel->name, version, tunnel->version); 853 856 goto error; 854 857 } 855 858 ··· 886 891 l2tp_session_dec_refcount(session); 887 892 888 893 /* Not found? Pass to userspace to deal with */ 889 - l2tp_warn(tunnel, L2TP_MSG_DATA, 890 - "%s: no session found (%u/%u). Passing up.\n", 891 - tunnel->name, tunnel_id, session_id); 894 + pr_warn_ratelimited("%s: no session found (%u/%u). Passing up.\n", 895 + tunnel->name, tunnel_id, session_id); 892 896 goto error; 893 897 } 894 898
+1 -1
net/l2tp/l2tp_ppp.c
··· 251 251 252 252 no_sock: 253 253 rcu_read_unlock(); 254 - l2tp_warn(session, L2TP_MSG_DATA, "%s: no socket\n", session->name); 254 + pr_warn_ratelimited("%s: no socket in recv\n", session->name); 255 255 kfree_skb(skb); 256 256 } 257 257