Skip to content

Commit

Permalink
ldpd: fix wrong gtsm count
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
anlancs committed Jun 15, 2024
1 parent 045029e commit e9aa953
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ldpd/neighbor.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,15 +683,23 @@ 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)
return (-1);
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);
Expand Down

0 comments on commit e9aa953

Please sign in to comment.