def test_llgr_ctrl(self): ''' Check Traffic to VM on different host goes fine when BGP session is down during GR and LLGR configuration holdtime of 90sec + llgr stale time of 60sec ''' #enable llgr # holdtime of 90sec + stale time of 30sec timeout = 100 self.set_gr_llgr(gr=0, llgr=60, mode='enable') #self.set_gr_llgr(mode='disable') if not self.create_vm_start_ping(ping_count=6000): self.logger.error("Error in creating VM") return False session, pcap_file = start_tcpdump_for_intf( self.inputs.bgp_ips[0], self.inputs.host_data[self.inputs.bgp_ips[0]]['username'], self.inputs.host_data[self.inputs.bgp_ips[0]]['password'], 'bond0', filters='-vvv port bgp') self.set_bgp_peering(mode='disable') self.addCleanup(self.set_bgp_peering, mode='enable') time.sleep(timeout) if not self.verify_gr_llgr_flags(flags=['Stale', 'LlgrStale'], vn_fix=self.vn_fix, prefix=self.vm2_fixture.vm_ip): self.logger.error("Stale flag is not set for route : %s" % self.vm2_fixture.vm_ip) return False if not self.verify_gr_llgr_flags(flags=['Stale', 'LlgrStale'], vn_fix=self.vn_fix, prefix=self.ipv6_addr): self.logger.error("Stale flag is not set for route : %s" % self.ipv6_addr) return False if not self.verify_ping_stats(): self.logger.error("Error in ping stats") return False self.set_bgp_peering(mode='enable') time.sleep(20) stop_tcpdump_for_intf(session, pcap_file) if not self.verify_llgr_bgp_flags(pcap_file=pcap_file, host=self.inputs.bgp_ips[0]): self.logger.error("Error in llgr restart flags of Open message") return False return True
def test_gr_llgr_mx(self): ''' Check Traffic to MX goes fine when BGP session is down durin GR and LLGR configuration ''' timeout = 60 #enable llgr self.set_gr_llgr(gr=35, llgr=60, mode='enable') #self.set_gr_llgr(mode='disable') if not self.create_vm_start_ping(ping_count=60): self.logger.error("Error in creating VM") return False session, pcap_file = start_tcpdump_for_intf( self.inputs.bgp_ips[0], self.inputs.host_data[self.inputs.bgp_ips[0]]['username'], self.inputs.host_data[self.inputs.bgp_ips[0]]['password'], 'bond0', filters='-vvv port bgp') self.set_bgp_peering(mode='disable') self.addCleanup(self.set_bgp_peering, mode='enable') time.sleep(timeout) assert self.verify_gr_llgr_flags(flags=['Stale', 'LlgrStale'], vn_fix=self.vn_fix, prefix=self.mx_loopback_ip) assert self.verify_gr_llgr_flags(flags=['Stale', 'LlgrStale'], vn_fix=self.vn_fix, prefix=self.mx_loopback_ip6) if not self.verify_ping_stats(): self.logger.error("Error in ping stats") return False self.set_bgp_peering(mode='enable') time.sleep(20) stop_tcpdump_for_intf(session, pcap_file) if not self.verify_gr_bgp_flags(pcap_file=pcap_file, host=self.inputs.bgp_ips[0]): self.logger.error("Error in restart gr flags of Open message") return False if not self.verify_llgr_bgp_flags(pcap_file=pcap_file, host=self.inputs.bgp_ips[0]): self.logger.error("Error in restart llgr flags of Open message") return False return True
def test_llgr_ctrl(self): ''' Check Traffic to VM on different host goes fine when BGP session is down during GR and LLGR configuration holdtime of 90sec + llgr stale time of 60sec ''' #enable llgr # holdtime of 90sec + stale time of 30sec timeout = 100 self.set_gr_llgr(gr=0,llgr=60,mode='enable') #self.set_gr_llgr(mode='disable') if not self.create_vm_start_ping(ping_count=6000): self.logger.error("Error in creating VM") return False session , pcap_file = start_tcpdump_for_intf(self.inputs.bgp_ips[0], self.inputs.host_data[self.inputs.bgp_ips[0]]['username'], self.inputs.host_data[self.inputs.bgp_ips[0]]['password'], 'bond0', filters='-vvv port bgp') self.set_bgp_peering(mode='disable') self.addCleanup(self.set_bgp_peering,mode='enable') time.sleep(timeout) if not self.verify_gr_llgr_flags(flags=['Stale','LlgrStale'], vn_fix=self.vn_fix, prefix=self.vm2_fixture.vm_ip): self.logger.error("Stale flag is not set for route : %s"%self.vm2_fixture.vm_ip) return False if not self.verify_gr_llgr_flags(flags=['Stale','LlgrStale'], vn_fix=self.vn_fix, prefix=self.ipv6_addr): self.logger.error("Stale flag is not set for route : %s"%self.ipv6_addr) return False if not self.verify_ping_stats(): self.logger.error("Error in ping stats") return False self.set_bgp_peering(mode='enable') time.sleep(20) stop_tcpdump_for_intf(session, pcap_file) if not self.verify_llgr_bgp_flags(pcap_file=pcap_file,host=self.inputs.bgp_ips[0]): self.logger.error("Error in llgr restart flags of Open message") return False return True
def test_gr_mx_restart(self): ''' Check Traffic to MX goes fine when rpd is restarted during GR configuration ''' #enable llgr self.set_gr_llgr(gr=35, llgr=0, mode='enable') #self.set_gr_llgr(mode='disable') if not self.create_vm_start_ping(ping_count=30): self.logger.error("Error in creating VM") return False session, pcap_file = start_tcpdump_for_intf( self.inputs.bgp_ips[0], self.inputs.host_data[self.inputs.bgp_ips[0]]['username'], self.inputs.host_data[self.inputs.bgp_ips[0]]['password'], 'bond0', filters='-vvv port bgp') # restart rpd self.mx1_handle.restart('routing immediately') #self.stop_bgp_peering() time.sleep(self.timeout) assert self.verify_gr_llgr_flags(flags=['None'], vn_fix=self.vn_fix, prefix=self.mx_loopback_ip) assert self.verify_gr_llgr_flags(flags=['None'], vn_fix=self.vn_fix, prefix=self.mx_loopback_ip6) if not self.verify_ping_stats(): self.logger.error("Error in ping stats") return False time.sleep(20) stop_tcpdump_for_intf(session, pcap_file) if not self.verify_gr_bgp_flags(pcap_file=pcap_file, host=self.inputs.bgp_ips[0]): self.logger.error("Error in restart gr flags of Open message") return False return True
def test_gr_llgr_mx(self): ''' Check Traffic to MX goes fine when BGP session is down durin GR and LLGR configuration ''' timeout = 60 #enable llgr self.set_gr_llgr(gr=35,llgr=60,mode='enable') #self.set_gr_llgr(mode='disable') if not self.create_vm_start_ping(ping_count=60): self.logger.error("Error in creating VM") return False session , pcap_file = start_tcpdump_for_intf(self.inputs.bgp_ips[0], self.inputs.host_data[self.inputs.bgp_ips[0]]['username'], self.inputs.host_data[self.inputs.bgp_ips[0]]['password'], 'bond0', filters='-vvv port bgp') self.set_bgp_peering(mode='disable') self.addCleanup(self.set_bgp_peering,mode='enable') time.sleep(timeout) assert self.verify_gr_llgr_flags(flags=['Stale','LlgrStale'], vn_fix=self.vn_fix, prefix=self.mx_loopback_ip) assert self.verify_gr_llgr_flags(flags=['Stale','LlgrStale'], vn_fix=self.vn_fix, prefix=self.mx_loopback_ip6) if not self.verify_ping_stats(): self.logger.error("Error in ping stats") return False self.set_bgp_peering(mode='enable') time.sleep(20) stop_tcpdump_for_intf(session, pcap_file) if not self.verify_gr_bgp_flags(pcap_file=pcap_file,host=self.inputs.bgp_ips[0]): self.logger.error("Error in restart gr flags of Open message") return False if not self.verify_llgr_bgp_flags(pcap_file=pcap_file,host=self.inputs.bgp_ips[0]): self.logger.error("Error in restart llgr flags of Open message") return False return True
def test_gr_mx_restart(self): ''' Check Traffic to MX goes fine when rpd is restarted during GR configuration ''' #enable llgr self.set_gr_llgr(gr=35,llgr=0,mode='enable') #self.set_gr_llgr(mode='disable') if not self.create_vm_start_ping(ping_count=30): self.logger.error("Error in creating VM") return False session , pcap_file = start_tcpdump_for_intf(self.inputs.bgp_ips[0], self.inputs.host_data[self.inputs.bgp_ips[0]]['username'], self.inputs.host_data[self.inputs.bgp_ips[0]]['password'], 'bond0', filters='-vvv port bgp') # restart rpd self.mx1_handle.restart('routing immediately') #self.stop_bgp_peering() time.sleep(self.timeout) assert self.verify_gr_llgr_flags(flags=['None'], vn_fix=self.vn_fix, prefix=self.mx_loopback_ip) assert self.verify_gr_llgr_flags(flags=['None'], vn_fix=self.vn_fix, prefix=self.mx_loopback_ip6) if not self.verify_ping_stats(): self.logger.error("Error in ping stats") return False time.sleep(20) stop_tcpdump_for_intf(session, pcap_file) if not self.verify_gr_bgp_flags(pcap_file=pcap_file,host=self.inputs.bgp_ips[0]): self.logger.error("Error in restart gr flags of Open message") return False return True
def test_underlay_broadcast_traffic_handling(self): ''' Test the underlay brocast traffic handling by vrouter. (Bug-1545229). 1. Send broadcast traffic from one compute node. 2. Other compute in same subnet should receive that traffic. 3. Receiving compute should treat this traffic as underlay. 4. Compute should not replicate the packet and send the copy back. Pass criteria: Step 3-4 should pass ''' if (len(self.inputs.compute_ips) < 2): raise self.skipTest( "Skipping Test. At least 2 compute node required to run the test") result = True # Find ignore brocast exiting value ignore_broadcasts={} cmd='cat /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts' for item in self.inputs.compute_ips: ignore_broadcasts[item]=self.inputs.run_cmd_on_server( item, cmd, self.inputs.host_data[item]['username'], self.inputs.host_data[item]['password']) # Set ignore brocast to false cmd='echo "0" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts' for item in self.inputs.compute_ips: self.inputs.run_cmd_on_server( item, cmd, self.inputs.host_data[item]['username'], self.inputs.host_data[item]['password']) # Find the Brocast address from first compute cmd='ifconfig | grep %s' %(self.inputs.host_data[item]['host_control_ip']) output=self.inputs.run_cmd_on_server( item, cmd, self.inputs.host_data[item]['username'], self.inputs.host_data[item]['password']) broadcast_address=output.split(" ")[3].split(":")[1] # Start tcpdump on receiving compute inspect_h = self.agent_inspect[self.inputs.compute_ips[1]] comp_intf = inspect_h.get_vna_interface_by_type('eth') if len(comp_intf) == 1: comp_intf = comp_intf[0] self.logger.info('Agent interface name: %s' % comp_intf) compute_ip = self.inputs.compute_ips[1] compute_user = self.inputs.host_data[self.inputs.compute_ips[1]]['username'] compute_password = self.inputs.host_data[self.inputs.compute_ips[1]]['password'] filters = "host %s" %(broadcast_address) (session, pcap) = start_tcpdump_for_intf(compute_ip, compute_user, compute_password, comp_intf, filters, self.logger) sleep(5) # Ping broadcast address self.logger.info( 'Pinging broacast address %s from compute %s' %(broadcast_address,\ self.inputs.host_data[self.inputs.compute_ips[0]]['host_control_ip'])) packet_count = 10 cmd='ping -c %s -b %s' %(packet_count, broadcast_address) output=self.inputs.run_cmd_on_server( self.inputs.compute_ips[0], cmd, self.inputs.host_data[item]['username'], self.inputs.host_data[item]['password']) sleep(5) # Stop tcpdump stop_tcpdump_for_intf(session, pcap, self.logger) # Set back the ignore_broadcasts to original value for item in self.inputs.compute_ips: cmd='echo "%s" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts' %(ignore_broadcasts[item]) self.inputs.run_cmd_on_server( item, cmd, self.inputs.host_data[item]['username'], self.inputs.host_data[item]['password']) # Analyze pcap assert verify_tcpdump_count(self, session, pcap, exp_count=packet_count), "There should only be %s\ packet from source %s on compute %s" %(packet_count, broadcast_address, compute_ip) self.logger.info( 'Packet count matched: Compute %s has receive only %s packet from source IP %s.\ No duplicate packet seen' %(compute_ip, packet_count, broadcast_address)) return result
def stop_tcpdump(self, session, pcap): stop_tcpdump_for_intf(session, pcap, self.logger)
def test_underlay_broadcast_traffic_handling(self): ''' Test the underlay brocast traffic handling by vrouter. (Bug-1545229). 1. Send broadcast traffic from one compute node. 2. Other compute in same subnet should receive that traffic. 3. Receiving compute should treat this traffic as underlay. 4. Compute should not replicate the packet and send the copy back. Pass criteria: Step 3-4 should pass Maintainer : [email protected] ''' if (len(self.inputs.compute_ips) < 2): raise self.skipTest( "Skipping Test. At least 2 compute node required to run the test" ) result = True # Find ignore brocast exiting value ignore_broadcasts = {} cmd = 'cat /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts' for item in self.inputs.compute_ips: ignore_broadcasts[item] = self.inputs.run_cmd_on_server( item, cmd, self.inputs.host_data[item]['username'], self.inputs.host_data[item]['password']) # Set ignore brocast to false cmd = 'echo "0" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts' for item in self.inputs.compute_ips: self.inputs.run_cmd_on_server( item, cmd, self.inputs.host_data[item]['username'], self.inputs.host_data[item]['password']) # Find the Brocast address from first compute cmd = 'ifconfig | grep %s' % ( self.inputs.host_data[item]['host_control_ip']) output = self.inputs.run_cmd_on_server( item, cmd, self.inputs.host_data[item]['username'], self.inputs.host_data[item]['password']) broadcast_address = output.split(" ")[3].split(":")[1] # Start tcpdump on receiving compute inspect_h = self.agent_inspect[self.inputs.compute_ips[1]] comp_intf = inspect_h.get_vna_interface_by_type('eth') if len(comp_intf) == 1: comp_intf = comp_intf[0] self.logger.info('Agent interface name: %s' % comp_intf) compute_ip = self.inputs.compute_ips[1] compute_user = self.inputs.host_data[ self.inputs.compute_ips[1]]['username'] compute_password = self.inputs.host_data[ self.inputs.compute_ips[1]]['password'] filters = "host %s" % (broadcast_address) (session, pcap) = start_tcpdump_for_intf(compute_ip, compute_user, compute_password, comp_intf, filters, self.logger) sleep(5) # Ping broadcast address self.logger.info( 'Pinging broacast address %s from compute %s' %(broadcast_address,\ self.inputs.host_data[self.inputs.compute_ips[0]]['host_control_ip'])) packet_count = 10 cmd = 'ping -c %s -b %s' % (packet_count, broadcast_address) output = self.inputs.run_cmd_on_server( self.inputs.compute_ips[0], cmd, self.inputs.host_data[item]['username'], self.inputs.host_data[item]['password']) sleep(5) # Stop tcpdump stop_tcpdump_for_intf(session, pcap, self.logger) # Set back the ignore_broadcasts to original value for item in self.inputs.compute_ips: cmd = 'echo "%s" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts' % ( ignore_broadcasts[item]) self.inputs.run_cmd_on_server( item, cmd, self.inputs.host_data[item]['username'], self.inputs.host_data[item]['password']) # Analyze pcap assert verify_tcpdump_count( self, session, pcap, exp_count=packet_count), "There should only be %s\ packet from source %s on compute %s" % ( packet_count, broadcast_address, compute_ip) self.logger.info( 'Packet count matched: Compute %s has receive only %s packet from source IP %s.\ No duplicate packet seen' % (compute_ip, packet_count, broadcast_address)) return result