summaryrefslogtreecommitdiff
path: root/pimd/pim_pim.c
diff options
context:
space:
mode:
authorChirag Shah <chirag@cumulusnetworks.com>2017-01-12 17:15:44 -0800
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-02-14 15:52:56 -0500
commitd62c5c03816d8dc525424b04c6b4b3c3ad23a29c (patch)
treece8499f03319a00f32e918da1b57cc0c50b5a8fb /pimd/pim_pim.c
parent5637da0501faa600273ecd7a2ed39cdbbe4531b1 (diff)
pimd: messages to neighbors should have TTL = 1
Ticket:CM-12924 Reviewed By:shapd Testing Done: configure PIM neighbor, verify PIM hello packet dump for ttl to be 1. Set TTL to 1 for outgoing multicast control packets destine to ALL-PIM-ROUTERS as oppose to unicast mcast packets. Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
Diffstat (limited to 'pimd/pim_pim.c')
-rw-r--r--pimd/pim_pim.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/pimd/pim_pim.c b/pimd/pim_pim.c
index 840004c375..c96cc187c7 100644
--- a/pimd/pim_pim.c
+++ b/pimd/pim_pim.c
@@ -557,6 +557,8 @@ pim_msg_send(int fd, struct in_addr src,
socklen_t tolen;
unsigned char buffer[10000];
unsigned char *msg_start;
+ uint8_t ttl = MAXTTL;
+ enum pim_msg_type pim_type = PIM_MSG_TYPE_HELLO;
struct ip *ip;
memset (buffer, 0, 10000);
@@ -565,14 +567,36 @@ pim_msg_send(int fd, struct in_addr src,
msg_start = buffer + sizeof (struct ip);
memcpy (msg_start, pim_msg, pim_msg_size);
- ip = (struct ip *)buffer;
+ /* TTL for packets destine to ALL-PIM-ROUTERS is 1 */
+ pim_type = PIM_MSG_HDR_GET_TYPE (pim_msg);
+ switch (pim_type)
+ {
+ case PIM_MSG_TYPE_HELLO:
+ case PIM_MSG_TYPE_JOIN_PRUNE:
+ case PIM_MSG_TYPE_BOOTSTRAP:
+ case PIM_MSG_TYPE_ASSERT:
+ ttl = 1;
+ break;
+ case PIM_MSG_TYPE_REGISTER:
+ case PIM_MSG_TYPE_REG_STOP:
+ case PIM_MSG_TYPE_GRAFT:
+ case PIM_MSG_TYPE_GRAFT_ACK:
+ case PIM_MSG_TYPE_CANDIDATE:
+ ttl = IPDEFTTL;
+ break;
+ default:
+ ttl = MAXTTL;
+ break;
+ }
+
+ ip = (struct ip *) buffer;
ip->ip_id = htons (++ip_id);
ip->ip_hl = 5;
ip->ip_v = 4;
ip->ip_p = PIM_IP_PROTO_PIM;
ip->ip_src = src;
ip->ip_dst = dst;
- ip->ip_ttl = MAXTTL;
+ ip->ip_ttl = ttl;
ip->ip_len = htons (sendlen);
if (PIM_DEBUG_PIM_PACKETS) {