Merge pull request #18652 from donaldsharp/pim_ssmpingd
Some checks are pending
build-test / Build the x86 ubuntu 22.04 docker image (push) Waiting to run
build-test / Test ubuntu x86 docker image (push) Blocked by required conditions
build-test / Build the ARM ubuntu 22.04 docker image (push) Waiting to run
build-test / Test ubuntu ARM docker image (push) Blocked by required conditions

Fix Pim ssmpingd
This commit is contained in:
Jafar Al-Gharaibeh 2025-04-24 10:52:48 -05:00 committed by GitHub
commit 1b0bac0e68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 114 additions and 79 deletions

View file

@ -35,7 +35,8 @@ Installing Topotest Requirements
iputils-ping \ iputils-ping \
iptables \ iptables \
tshark \ tshark \
valgrind valgrind \
ssmping
python3 -m pip install wheel python3 -m pip install wheel
python3 -m pip install 'pytest>=8.3.2' 'pytest-asyncio>=0.24.0' 'pytest-xdist>=3.6.1' python3 -m pip install 'pytest>=8.3.2' 'pytest-asyncio>=0.24.0' 'pytest-xdist>=3.6.1'
python3 -m pip install 'scapy>=2.4.5' python3 -m pip install 'scapy>=2.4.5'

View file

@ -66,6 +66,7 @@ RUN apt update && apt upgrade -y && \
snmp \ snmp \
snmp-mibs-downloader \ snmp-mibs-downloader \
snmpd \ snmpd \
ssmping \
sudo \ sudo \
time \ time \
tshark \ tshark \

View file

@ -155,10 +155,13 @@ static inline int ssmpingd_setsockopt(int fd, pim_addr addr, int mttl)
static int ssmpingd_socket(pim_addr addr, int port, int mttl) static int ssmpingd_socket(pim_addr addr, int port, int mttl)
{ {
struct sockaddr_storage sockaddr; #if PIM_IPV == 4
struct sockaddr_in sockaddr;
#else
struct sockaddr_in6 sockaddr;
#endif
int fd; int fd;
int ret; int ret;
socklen_t len = sizeof(sockaddr);
fd = socket(PIM_AF, SOCK_DGRAM, IPPROTO_UDP); fd = socket(PIM_AF, SOCK_DGRAM, IPPROTO_UDP);
if (fd < 0) { if (fd < 0) {
@ -167,8 +170,15 @@ static int ssmpingd_socket(pim_addr addr, int port, int mttl)
__func__, errno, safe_strerror(errno)); __func__, errno, safe_strerror(errno));
return -1; return -1;
} }
#if PIM_IPV == 4
pim_socket_getsockname(fd, (struct sockaddr *)&sockaddr, &len); sockaddr.sin_addr = addr;
sockaddr.sin_port = htons(port);
sockaddr.sin_family = PIM_AF;
#else
sockaddr.sin6_addr = addr;
sockaddr.sin6_port = htons(port);
sockaddr.sin6_family = PIM_AF;
#endif
if (bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr))) { if (bind(fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr))) {
zlog_warn( zlog_warn(

View file

@ -1,5 +0,0 @@
router bgp 65001
no bgp ebgp-requires-policy
neighbor 10.0.30.3 remote-as external
neighbor 10.0.30.3 timers 3 10
redistribute connected

View file

@ -0,0 +1,32 @@
hostname r1
!
service integrated-vtysh-config
!
interface r1-eth0
ip address 10.0.20.1/24
ip igmp
ip pim
!
interface r1-eth1
ip address 10.0.30.1/24
ip pim
!
interface r1-eth2
ip address 10.0.40.1/24
ip igmp
ip pim
!
interface lo
ip address 10.254.0.1/32
ip pim
!
router bgp 65001
no bgp ebgp-requires-policy
neighbor 10.0.30.3 remote-as external
neighbor 10.0.30.3 timers 3 10
redistribute connected
!
router pim
rp 10.254.0.3
join-prune-interval 5
!

View file

@ -1,18 +0,0 @@
hostname r1
!
interface r1-eth0
ip igmp
ip pim
!
interface r1-eth1
ip pim
!
interface r1-eth2
ip igmp
ip pim
!
interface lo
ip pim
!
ip pim rp 10.254.0.3
ip pim join-prune-interval 5

View file

@ -1,14 +0,0 @@
hostname r1
!
interface r1-eth0
ip address 10.0.20.1/24
!
interface r1-eth1
ip address 10.0.30.1/24
!
interface r1-eth2
ip address 10.0.40.1/24
!
interface lo
ip address 10.254.0.1/32
!

View file

@ -1,8 +1,15 @@
hostname r2 hostname r2
! !
frr version 8.4
frr defaults traditional
!
service integrated-vtysh-config
!
interface r2-eth0 interface r2-eth0
ip address 10.0.20.2/24 ip address 10.0.20.2/24
! !
interface lo interface lo
ip address 10.254.0.2/32 ip address 10.254.0.2/32
! !
line vty
!

View file

@ -1 +0,0 @@
hostname r2

View file

@ -1,5 +1,8 @@
hostname r3 hostname r3
! !
!
service integrated-vtysh-config
!
interface r3-eth0 interface r3-eth0
ip address 10.0.40.4/24 ip address 10.0.40.4/24
! !

View file

@ -1 +0,0 @@
hostname r3

View file

@ -1,5 +0,0 @@
router bgp 65003
no bgp ebgp-requires-policy
neighbor 10.0.30.1 remote-as external
neighbor 10.0.30.1 timers 3 10
redistribute connected

View file

@ -0,0 +1,26 @@
hostname rp
!
!
service integrated-vtysh-config
!
interface rp-eth0
ip address 10.0.30.3/24
ip pim
!
interface lo
ip address 10.254.0.3/32
ip pim
!
router bgp 65003
no bgp ebgp-requires-policy
neighbor 10.0.30.1 remote-as external
neighbor 10.0.30.1 timers 3 10
redistribute connected
!
router pim
join-prune-interval 5
rp 10.254.0.3
register-accept-list ACCEPT
!
ip prefix-list ACCEPT seq 5 permit 10.0.20.0/24 le 32
!

View file

@ -1,13 +0,0 @@
hostname rp
!
interface rp-eth0
ip pim
!
interface lo
ip pim
!
ip pim join-prune-interval 5
ip pim rp 10.254.0.3
ip pim register-accept-list ACCEPT
ip prefix-list ACCEPT seq 5 permit 10.0.20.0/24 le 32

View file

@ -1,8 +0,0 @@
hostname rp
!
interface rp-eth0
ip address 10.0.30.3/24
!
interface lo
ip address 10.254.0.3/32
!

View file

@ -71,16 +71,15 @@ def setup_module(mod):
tgen = Topogen(build_topo, mod.__name__) tgen = Topogen(build_topo, mod.__name__)
tgen.start_topology() tgen.start_topology()
# For all registered routers, load the zebra configuration file # For all registered routers, load the integrated configuration file
for rname, router in tgen.routers().items(): for rname, router in tgen.routers().items():
router.load_config( router.load_frr_config(
TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname)) os.path.join(CWD, "{}/frr.conf".format(rname)),
) [
router.load_config( (TopoRouter.RD_ZEBRA, None),
TopoRouter.RD_PIM, os.path.join(CWD, "{}/pimd.conf".format(rname)) (TopoRouter.RD_PIM, None),
) (TopoRouter.RD_BGP, None),
router.load_config( ],
TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname))
) )
# After loading the configurations, this function loads configured daemons. # After loading the configurations, this function loads configured daemons.
@ -218,6 +217,27 @@ def test_pim_igmp_report():
p.wait() p.wait()
def test_pim_ssm_ping():
"Test SSM ping functionality between r1 and r2"
logger.info("Testing SSM ping from r1 to r2")
tgen = get_topogen()
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
r1 = tgen.gears["r1"]
r2 = tgen.gears["r2"]
r2.vtysh_cmd("conf\nip ssmpingd 10.0.20.2")
# Run ssmping from r1 to r2
output = r1.run("ssmping -I r1-eth0 10.0.20.2 -c 5")
# Check if we got successful responses
assert "5 packets received" in output, "SSM ping failed"
def test_memory_leak(): def test_memory_leak():
"Run the memory leak test and report results." "Run the memory leak test and report results."
tgen = get_topogen() tgen = get_topogen()