]> git.proxmox.com Git - mirror_frr.git/commitdiff
pimd: PIM Msg header includes N bit as defined by RFC
authorsaravanank <saravanank@vmware.com>
Sat, 4 May 2019 12:07:39 +0000 (05:07 -0700)
committersaravanank <saravanank@vmware.com>
Wed, 15 May 2019 04:40:50 +0000 (21:40 -0700)
This commit includes parsing of Nbit and contructing pim hdr with Nbit
Adding Nbit to PIm hdr structure
Adding Scope zone bit and Bidir bit to Encoded IPv4 Group Address

Signed-off-by: Saravanan K <saravanank@vmware.com>
pimd/pim_assert.c
pimd/pim_join.c
pimd/pim_msg.c
pimd/pim_msg.h
pimd/pim_pim.c
pimd/pim_register.c

index 0a450834e3efe55909f2791c7e786e4f369dd69a..438a0c9b64dba825bc817f2fb0eebf6c2d9af0e8 100644 (file)
@@ -418,7 +418,7 @@ int pim_assert_build_msg(uint8_t *pim_msg, int buf_size, struct interface *ifp,
          Add PIM header
        */
        pim_msg_size = pim_msg_curr - pim_msg;
-       pim_msg_build_header(pim_msg, pim_msg_size, PIM_MSG_TYPE_ASSERT);
+       pim_msg_build_header(pim_msg, pim_msg_size, PIM_MSG_TYPE_ASSERT, false);
 
        return pim_msg_size;
 }
index cbacaf3ea872733b4c749c3875e2230cf6c68bb2..5e1a4f0c5e6a13a5850b6a3d1268402faca40781 100644 (file)
@@ -519,7 +519,7 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups)
                group_size = pim_msg_get_jp_group_size(group->sources);
                if (group_size > packet_left) {
                        pim_msg_build_header(pim_msg, packet_size,
-                                            PIM_MSG_TYPE_JOIN_PRUNE);
+                                            PIM_MSG_TYPE_JOIN_PRUNE, false);
                        if (pim_msg_send(pim_ifp->pim_sock_fd,
                                         pim_ifp->primary_address,
                                         qpim_all_pim_routers_addr, pim_msg,
@@ -576,7 +576,7 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups)
                if (packet_left < sizeof(struct pim_jp_groups)
                    || msg->num_groups == 255) {
                        pim_msg_build_header(pim_msg, packet_size,
-                                            PIM_MSG_TYPE_JOIN_PRUNE);
+                                            PIM_MSG_TYPE_JOIN_PRUNE, false);
                        if (pim_msg_send(pim_ifp->pim_sock_fd,
                                         pim_ifp->primary_address,
                                         qpim_all_pim_routers_addr, pim_msg,
@@ -596,7 +596,7 @@ int pim_joinprune_send(struct pim_rpf *rpf, struct list *groups)
        if (!new_packet) {
                // msg->num_groups = htons (msg->num_groups);
                pim_msg_build_header(pim_msg, packet_size,
-                                    PIM_MSG_TYPE_JOIN_PRUNE);
+                                    PIM_MSG_TYPE_JOIN_PRUNE, false);
                if (pim_msg_send(pim_ifp->pim_sock_fd, pim_ifp->primary_address,
                                 qpim_all_pim_routers_addr, pim_msg,
                                 packet_size,
index 63688f87e055d92fd918996ab1a53d12f3c58289..2e467502b1feb38261dfbc8ab23a88d40a348791 100644 (file)
@@ -39,7 +39,7 @@
 #include "pim_oil.h"
 
 void pim_msg_build_header(uint8_t *pim_msg, size_t pim_msg_size,
-                         uint8_t pim_msg_type)
+                         uint8_t pim_msg_type, bool no_fwd)
 {
        struct pim_msg_header *header = (struct pim_msg_header *)pim_msg;
 
@@ -48,6 +48,7 @@ void pim_msg_build_header(uint8_t *pim_msg, size_t pim_msg_size,
         */
        header->ver = PIM_PROTO_VERSION;
        header->type = pim_msg_type;
+       header->Nbit = no_fwd;
        header->reserved = 0;
 
 
index ad9b5d9c01e6d457762acbff4dde100c6453bb29..5f5030396750cc4cb9b0a6694e4cfd0b965d8d27 100644 (file)
@@ -23,6 +23,8 @@
 #include <netinet/in.h>
 
 #include "pim_jp_agg.h"
+
+#define PIM_HDR_LEN  sizeof(struct pim_msg_header)
 /*
   Number       Description
   ----------   ------------------
@@ -41,11 +43,20 @@ enum pim_msg_address_family {
 
 /*
  * Network Order pim_msg_hdr
+ * =========================
+ *  PIM Header definition as per RFC 5059. N bit introduced to indicate
+ *  do-not-forward option in PIM Boot strap Message.
+ *    0                   1                   2                   3
+ *   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *  |PIM Ver| Type  |N|  Reserved   |           Checksum            |
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 struct pim_msg_header {
        uint8_t type : 4;
        uint8_t ver : 4;
-       uint8_t reserved;
+       uint8_t Nbit : 1; /* No Fwd Bit */
+       uint8_t reserved : 7;
        uint16_t checksum;
 } __attribute__((packed));
 
@@ -58,7 +69,9 @@ struct pim_encoded_ipv4_unicast {
 struct pim_encoded_group_ipv4 {
        uint8_t ne;
        uint8_t family;
-       uint8_t reserved;
+       uint8_t bidir : 1;      /* Bidir bit */
+       uint8_t reserved : 6;   /* Reserved */
+       uint8_t sz : 1;         /* scope zone bit */
        uint8_t mask;
        struct in_addr addr;
 } __attribute__((packed));
@@ -88,7 +101,7 @@ struct pim_jp {
 } __attribute__((packed));
 
 void pim_msg_build_header(uint8_t *pim_msg, size_t pim_msg_size,
-                         uint8_t pim_msg_type);
+                         uint8_t pim_msg_type, bool no_fwd);
 uint8_t *pim_msg_addr_encode_ipv4_ucast(uint8_t *buf, struct in_addr addr);
 uint8_t *pim_msg_addr_encode_ipv4_group(uint8_t *buf, struct in_addr addr);
 
index 71b0d479281be1de3b66cd138f32d8a1d562d8cd..e9d44b9c3c09e0fcfd7ffd66189f0f69c58e7a2a 100644 (file)
@@ -39,6 +39,7 @@
 #include "pim_msg.h"
 #include "pim_register.h"
 #include "pim_errors.h"
+#include "pim_bsm.h"
 
 static int on_pim_hello_send(struct thread *t);
 static int pim_hello_send(struct interface *ifp, uint16_t holdtime);
@@ -273,6 +274,7 @@ int pim_pim_packet(struct interface *ifp, uint8_t *buf, size_t len)
                                       pim_msg + PIM_MSG_HEADER_LEN,
                                       pim_msg_len - PIM_MSG_HEADER_LEN);
                break;
+
        default:
                if (PIM_DEBUG_PIM_PACKETS) {
                        zlog_debug(
@@ -634,7 +636,7 @@ static int hello_send(struct interface *ifp, uint16_t holdtime)
        zassert(pim_msg_size >= PIM_PIM_MIN_LEN);
        zassert(pim_msg_size <= PIM_PIM_BUFSIZE_WRITE);
 
-       pim_msg_build_header(pim_msg, pim_msg_size, PIM_MSG_TYPE_HELLO);
+       pim_msg_build_header(pim_msg, pim_msg_size, PIM_MSG_TYPE_HELLO, false);
 
        if (pim_msg_send(pim_ifp->pim_sock_fd, pim_ifp->primary_address,
                         qpim_all_pim_routers_addr, pim_msg, pim_msg_size,
index 431236eebe720f2f2717bf0802caedebb313cc2c..3fe7e8bf640e788573a05529dffe6bcfeb359289 100644 (file)
@@ -94,7 +94,7 @@ void pim_register_stop_send(struct interface *ifp, struct prefix_sg *sg,
        b1length += length;
 
        pim_msg_build_header(buffer, b1length + PIM_MSG_REGISTER_STOP_LEN,
-                            PIM_MSG_TYPE_REG_STOP);
+                            PIM_MSG_TYPE_REG_STOP, false);
 
        pinfo = (struct pim_interface *)ifp->info;
        if (!pinfo) {
@@ -208,7 +208,7 @@ void pim_register_send(const uint8_t *buf, int buf_size, struct in_addr src,
        memcpy(b1, (const unsigned char *)buf, buf_size);
 
        pim_msg_build_header(buffer, buf_size + PIM_MSG_REGISTER_LEN,
-                            PIM_MSG_TYPE_REGISTER);
+                            PIM_MSG_TYPE_REGISTER, false);
 
        ++pinfo->pim_ifstat_reg_send;