diff options
author | Guillaume Nault <g.nault@alphalink.fr> | 2013-03-25 12:47:35 +0100 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2013-03-28 07:16:19 +0400 |
commit | ebc5f7207790f7c055c7818bf68cb5f4c3d5d70f (patch) | |
tree | eca42e4100117ecc7dfd272615bcb28d7da95733 /accel-pppd/ctrl | |
parent | f6e23c2c28d5f36efe2a99eaccba2e6f7eae80b2 (diff) | |
download | accel-ppp-ebc5f7207790f7c055c7818bf68cb5f4c3d5d70f.tar.gz accel-ppp-ebc5f7207790f7c055c7818bf68cb5f4c3d5d70f.zip |
l2tp: Use consistent packet logging policy
Adapt packet logging policy to make it consistent across L2TP packet
handling functions:
* Don't log messages if conf_verbose is off.
* Log HELLO and ZLB messages with log_debug and use log_info2 for
any other message type.
* Log retransmissions with log_info2, no matter the message type.
* Log outgoing messages right before sending them.
* Log incoming messages right before analysing their message type.
This unifies the way l2tp_conn_read() and l2tp_udp_read() log
incoming messages.
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Diffstat (limited to 'accel-pppd/ctrl')
-rw-r--r-- | accel-pppd/ctrl/l2tp/l2tp.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c index bfc3ab1..829e571 100644 --- a/accel-pppd/ctrl/l2tp/l2tp.c +++ b/accel-pppd/ctrl/l2tp/l2tp.c @@ -1322,9 +1322,8 @@ static int l2tp_retransmit(struct l2tp_conn_t *conn) pack = list_entry(conn->send_queue.next, typeof(*pack), entry); pack->hdr.Nr = htons(conn->Nr); if (conf_verbose) { - l2tp_conn_log(log_debug, conn); - log_debug("send "); - l2tp_packet_print(pack, log_debug); + log_tunnel(log_info2, conn, "retransmit (duplicate) "); + l2tp_packet_print(pack, log_info2); } if (l2tp_packet_send(conn->hnd.fd, pack) < 0) { log_tunnel(log_error, conn, @@ -1346,8 +1345,9 @@ static void l2tp_rtimeout(struct triton_timer_t *t) pack = list_entry(conn->send_queue.next, typeof(*pack), entry); pack->hdr.Nr = htons(conn->Nr); if (conf_verbose) { - log_ppp_debug("send "); - l2tp_packet_print(pack, log_ppp_debug); + log_tunnel(log_info2, conn, + "retransmit (timeout) "); + l2tp_packet_print(pack, log_info2); } if (l2tp_packet_send(conn->hnd.fd, pack) < 0) log_tunnel(log_error, conn, @@ -1971,12 +1971,6 @@ static int l2tp_recv_SCCRQ(const struct l2tp_serv_t *serv, return -1; } - if (conf_verbose) { - log_switch(&conn->ctx, NULL); - log_ppp_info2("recv "); - l2tp_packet_print(pack, log_ppp_info2); - } - if (l2tp_tunnel_storechall(conn, challenge) < 0) { log_error("l2tp: impossible to handle SCCRQ from %s:" " storing challenge failed\n", src_addr); @@ -3101,6 +3095,10 @@ static int l2tp_conn_read(struct triton_md_handler_t *h) } if (list_empty(&pack->attrs)) { + if (conf_verbose) { + log_tunnel(log_debug, conn, "recv "); + l2tp_packet_print(pack, log_debug); + } l2tp_packet_free(pack); continue; } @@ -3117,12 +3115,10 @@ static int l2tp_conn_read(struct triton_md_handler_t *h) if (conf_verbose) { if (msg_type->val.uint16 == Message_Type_Hello) { - l2tp_conn_log(log_debug, conn); - log_debug("recv "); + log_tunnel(log_debug, conn, "recv "); l2tp_packet_print(pack, log_debug); } else { - l2tp_conn_log(log_info2, conn); - log_info2("recv "); + log_tunnel(log_info2, conn, "recv "); l2tp_packet_print(pack, log_info2); } } @@ -3249,13 +3245,13 @@ static int l2tp_udp_read(struct triton_md_handler_t *h) goto skip; } + if (conf_verbose) { + log_info2("l2tp: recv "); + l2tp_packet_print(pack, log_info2); + } if (msg_type->val.uint16 == Message_Type_Start_Ctrl_Conn_Request) l2tp_recv_SCCRQ(serv, pack, &pkt_info); else { - if (conf_verbose) { - log_warn("recv (unexpected) "); - l2tp_packet_print(pack, log_ppp_warn); - } log_warn("l2tp: discarding unexpected message from %s:" " invalid Message Type %i\n", src_addr, msg_type->val.uint16); |