summaryrefslogtreecommitdiff
path: root/ldpd
diff options
context:
space:
mode:
authoranlan_cs <anlan_cs@tom.com>2024-06-15 20:34:20 +0800
committeranlan_cs <vic.lan@pica8.com>2024-06-15 23:30:18 +0800
commit1919df3a64d3fe6d4084c1d0b050b3e368860170 (patch)
tree2858cec5efc02d850485066da1b7ddeb907de570 /ldpd
parent045029e2442dbca3b6e7685438d171fa05c0f968 (diff)
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 <vic.lan@pica8.com>
Diffstat (limited to 'ldpd')
-rw-r--r--ldpd/neighbor.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/ldpd/neighbor.c b/ldpd/neighbor.c
index d40728b043..2596c79481 100644
--- a/ldpd/neighbor.c
+++ b/ldpd/neighbor.c
@@ -681,6 +681,18 @@ nbr_gtsm_setup(int fd, int af, struct nbr_params *nbrp)
if (nbrp && CHECK_FLAG(nbrp->flags, F_NBRP_GTSM_HOPS))
ttl = 256 - nbrp->gtsm_hops;
+ /*
+ * 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.
+ * This behavior is based on the new kernel (5.10 and 6.1),
+ * and older versions may behave differently.
+ *
+ * Here, decrease 1 for IP_MINTTL if GTSM is enabled.
+ * And this workaround makes the GTSM mechanism a bit deviation.
+ */
+ ttl -= 1;
+
switch (af) {
case AF_INET:
if (sock_set_ipv4_minttl(fd, ttl) == -1)