@pytest.fixture(scope='module')
def populate_vlan_arp_entries(setup, ptfhost, duthosts, rand_one_dut_hostname, ip_version):
    'Set up the ARP responder utility in the PTF container.'
    duthost = duthosts[rand_one_dut_hostname]
    if (setup['topo'] != 't0'):

        def noop():
            pass
        (yield noop)
        return
    addr_list = [DOWNSTREAM_DST_IP[ip_version], DOWNSTREAM_IP_TO_ALLOW[ip_version], DOWNSTREAM_IP_TO_BLOCK[ip_version]]
    vlan_host_map = defaultdict(dict)
    for i in range(len(addr_list)):
        mac = VLAN_BASE_MAC_PATTERN.format(i)
        port = random.choice(setup['vlan_ports'])
        addr = addr_list[i]
        vlan_host_map[port][str(addr)] = mac
        DOWNSTREAM_IP_PORT_MAP[addr] = port
    arp_responder_conf = {}
    for port in vlan_host_map:
        arp_responder_conf['eth{}'.format(port)] = vlan_host_map[port]
    with open('/tmp/from_t1.json', 'w') as ar_config:
        json.dump(arp_responder_conf, ar_config)
    ptfhost.copy(src='/tmp/from_t1.json', dest='/tmp/from_t1.json')
    ptfhost.host.options['variable_manager'].extra_vars.update({'arp_responder_args': '-e'})
    ptfhost.template(src='templates/arp_responder.conf.j2', dest='/etc/supervisor/conf.d/arp_responder.conf')
    ptfhost.shell('supervisorctl reread && supervisorctl update')
    ptfhost.shell('supervisorctl restart arp_responder')

    def populate_arp_table():
        for dut in duthosts:
            dut.command('sonic-clear fdb all')
            dut.command('sonic-clear arp')
            time.sleep(20)
            for addr in addr_list:
                dut.command('ping {} -c 3'.format(addr), module_ignore_errors=True)
    populate_arp_table()
    (yield populate_arp_table)
    logging.info('Stopping ARP responder')
    ptfhost.shell('supervisorctl stop arp_responder')
    duthost.command('sonic-clear fdb all')
    duthost.command('sonic-clear arp')
Set up the ARP responder utility in the PTF container.
@pytest.fixture(scope='module')
def populate_vlan_arp_entries(setup, ptfhost, duthosts, rand_one_dut_hostname, ip_version):
    
    duthost = duthosts[rand_one_dut_hostname]
    if (setup['topo'] != 't0'):

        def noop():
            pass
        (yield noop)
        return
    addr_list = [DOWNSTREAM_DST_IP[ip_version], DOWNSTREAM_IP_TO_ALLOW[ip_version], DOWNSTREAM_IP_TO_BLOCK[ip_version]]
    vlan_host_map = defaultdict(dict)
    for i in range(len(addr_list)):
        mac = VLAN_BASE_MAC_PATTERN.format(i)
        port = random.choice(setup['vlan_ports'])
        addr = addr_list[i]
        vlan_host_map[port][str(addr)] = mac
        DOWNSTREAM_IP_PORT_MAP[addr] = port
    arp_responder_conf = {}
    for port in vlan_host_map:
        arp_responder_conf['eth{}'.format(port)] = vlan_host_map[port]
    with open('/tmp/from_t1.json', 'w') as ar_config:
        json.dump(arp_responder_conf, ar_config)
    ptfhost.copy(src='/tmp/from_t1.json', dest='/tmp/from_t1.json')
    ptfhost.host.options['variable_manager'].extra_vars.update({'arp_responder_args': '-e'})
    ptfhost.template(src='templates/arp_responder.conf.j2', dest='/etc/supervisor/conf.d/arp_responder.conf')
    ptfhost.shell('supervisorctl reread && supervisorctl update')
    ptfhost.shell('supervisorctl restart arp_responder')

    def populate_arp_table():
        for dut in duthosts:
            dut.command('sonic-clear fdb all')
            dut.command('sonic-clear arp')
            time.sleep(20)
            for addr in addr_list:
                dut.command('ping {} -c 3'.format(addr), module_ignore_errors=True)
    populate_arp_table()
    (yield populate_arp_table)
    logging.info('Stopping ARP responder')
    ptfhost.shell('supervisorctl stop arp_responder')
    duthost.command('sonic-clear fdb all')
    duthost.command('sonic-clear arp')