Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/ldpd Be a little more strict when sending notificat...



details:   https://anonhg.NetBSD.org/src/rev/9480f9a8e0b4
branches:  trunk
changeset: 784458:9480f9a8e0b4
user:      kefren <kefren%NetBSD.org@localhost>
date:      Mon Jan 28 21:35:34 2013 +0000

description:
Be a little more strict when sending notifications and checking PDU

diffstat:

 usr.sbin/ldpd/ldp_errors.h |   3 ++-
 usr.sbin/ldpd/ldp_peer.c   |   5 +++--
 usr.sbin/ldpd/pdu.c        |  17 ++++++++++++++---
 usr.sbin/ldpd/socketops.c  |   4 ++--
 4 files changed, 21 insertions(+), 8 deletions(-)

diffs (97 lines):

diff -r 36e0912495c4 -r 9480f9a8e0b4 usr.sbin/ldpd/ldp_errors.h
--- a/usr.sbin/ldpd/ldp_errors.h        Mon Jan 28 21:08:14 2013 +0000
+++ b/usr.sbin/ldpd/ldp_errors.h        Mon Jan 28 21:35:34 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ldp_errors.h,v 1.4 2013/01/26 17:29:55 kefren Exp $ */
+/* $NetBSD: ldp_errors.h,v 1.5 2013/01/28 21:35:34 kefren Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -48,6 +48,7 @@
 #define        LDP_E_TOO_MANY_LABELS   13
 #define        LDP_E_INVAL             14
 #define        LDP_E_TOO_MANY_FDS      15
+#define        LDP_E_BAD_ID            16
 #define        LDP_E_GENERIC           255
 
 void   printtime(void);
diff -r 36e0912495c4 -r 9480f9a8e0b4 usr.sbin/ldpd/ldp_peer.c
--- a/usr.sbin/ldpd/ldp_peer.c  Mon Jan 28 21:08:14 2013 +0000
+++ b/usr.sbin/ldpd/ldp_peer.c  Mon Jan 28 21:35:34 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ldp_peer.c,v 1.7 2013/01/28 21:08:14 kefren Exp $ */
+/* $NetBSD: ldp_peer.c,v 1.8 2013/01/28 21:35:34 kefren Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -193,7 +193,8 @@
        SLIST_FOREACH(p, &ldp_peer_head, peers) {
                if ((p->state == LDP_PEER_ESTABLISHED) ||
                    (p->state == LDP_PEER_CONNECTED))
-                       send_notification(p, get_message_id(), NOTIF_SHUTDOWN);
+                       send_notification(p, get_message_id(),
+                           NOTIF_FATAL | NOTIF_SHUTDOWN);
                ldp_peer_holddown(p);
        }
 }
diff -r 36e0912495c4 -r 9480f9a8e0b4 usr.sbin/ldpd/pdu.c
--- a/usr.sbin/ldpd/pdu.c       Mon Jan 28 21:08:14 2013 +0000
+++ b/usr.sbin/ldpd/pdu.c       Mon Jan 28 21:35:34 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pdu.c,v 1.2 2013/01/26 17:29:55 kefren Exp $ */
+/* $NetBSD: pdu.c,v 1.3 2013/01/28 21:35:35 kefren Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -66,12 +66,22 @@
        if (c < MIN_PDU_SIZE)
                return LDP_E_BAD_LENGTH;
 
+       if (p->ldp_id.s_addr != rpdu->ldp_id.s_addr) {
+               fatalp("Invalid LDP ID received from %s\n",
+                   inet_ntoa(p->ldp_id));
+               notiftlv = build_notification(0,
+                   NOTIF_FATAL | NOTIF_BAD_LDP_ID);
+               send_tlv(p, (struct tlv *) notiftlv);
+               free(notiftlv);
+               return LDP_E_BAD_ID;
+       }
 
        /* Check PDU for right LDP version */
        if (ntohs(rpdu->version) != LDP_VERSION) {
                fatalp("Invalid PDU version received from %s (%d)\n",
                       satos(p->address), ntohs(rpdu->version));
-               notiftlv = build_notification(0, NOTIF_BAD_LDP_VER);
+               notiftlv = build_notification(0,
+                   NOTIF_FATAL | NOTIF_BAD_LDP_VER);
                send_tlv(p, (struct tlv *) notiftlv);
                free(notiftlv);
                return LDP_E_BAD_VERSION;
@@ -81,7 +91,8 @@
                fatalp("Invalid PDU length received from %s (announced %d, "
                    "received %d)\n", satos(p->address),
                    ntohs(rpdu->length), (int) (c - PDU_VER_LENGTH));
-               notiftlv = build_notification(0, NOTIF_BAD_PDU_LEN);
+               notiftlv = build_notification(0,
+                   NOTIF_FATAL | NOTIF_BAD_PDU_LEN);
                send_tlv(p, (struct tlv *) notiftlv);
                free(notiftlv);
                return LDP_E_BAD_LENGTH;
diff -r 36e0912495c4 -r 9480f9a8e0b4 usr.sbin/ldpd/socketops.c
--- a/usr.sbin/ldpd/socketops.c Mon Jan 28 21:08:14 2013 +0000
+++ b/usr.sbin/ldpd/socketops.c Mon Jan 28 21:35:34 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: socketops.c,v 1.22 2013/01/28 20:32:04 kefren Exp $ */
+/* $NetBSD: socketops.c,v 1.23 2013/01/28 21:35:35 kefren Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -734,7 +734,7 @@
                        case LDP_PEER_ESTABLISHED:
                        case LDP_PEER_CONNECTED:
                                send_notification(p, 0,
-                                   NOTIF_KEEP_ALIVE_TIMER_EXPIRED);
+                                   NOTIF_FATAL|NOTIF_KEEP_ALIVE_TIMER_EXPIRED);
                                warnp("Keepalive expired for %s\n",
                                    inet_ntoa(p->ldp_id));
                                ldp_peer_holddown(p);



Home | Main Index | Thread Index | Old Index