From e9aa95348ccaf82d6ded0c81b9b89e36901c876a Mon Sep 17 00:00:00 2001 From: anlan_cs Date: Sat, 15 Jun 2024 20:34:20 +0800 Subject: [PATCH] ldpd: fix wrong gtsm count In linux networking stack, the received mpls packets will be processed by the host *twice*, one as mpls packet, the other as ip packet, so its ttl decreased 1. So, we need release the `IP_MINTTL` value if gtsm is enabled, it is for the mpls packets of neighbor session caused by the command: `label local advertise explicit-null`. This change makes the gtsm mechanism a bit deviation. Fix PR #8313 Signed-off-by: anlan_cs --- ldpd/neighbor.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ldpd/neighbor.c b/ldpd/neighbor.c index d40728b0436b..9bcd01dee53b 100644 --- a/ldpd/neighbor.c +++ b/ldpd/neighbor.c @@ -683,7 +683,14 @@ nbr_gtsm_setup(int fd, int af, struct nbr_params *nbrp) switch (af) { case AF_INET: - if (sock_set_ipv4_minttl(fd, ttl) == -1) + /* + * In linux networking stack, the received mpls packets + * will be processed by the host twice, one as mpls packet, + * the other as ip packet, so its ttl will be decreased 1. + * + * Here, decrease 1 for IP_MINTTL if GTSM is enabled. + */ + if (sock_set_ipv4_minttl(fd, ttl - 1) == -1) return (-1); ttl = 255; if (sock_set_ipv4_ucast_ttl(fd, ttl) == -1) @@ -691,7 +698,8 @@ nbr_gtsm_setup(int fd, int af, struct nbr_params *nbrp) break; case AF_INET6: /* ignore any possible error */ - sock_set_ipv6_minhopcount(fd, ttl); + /* decrease 1 for IP_MINTTL, same to AF_INET */ + sock_set_ipv6_minhopcount(fd, ttl - 1); ttl = 255; if (sock_set_ipv6_ucast_hops(fd, ttl) == -1) return (-1);