def add_ipaddr(ptfadapter, ptfhost, nexthop_addrs, prefix_len, nexthop_interfaces, ipv6=False):
    if ipv6:
        for idx in range(len(nexthop_addrs)):
            ptfhost.shell('ip -6 addr add {}/{} dev eth{}'.format(nexthop_addrs[idx], prefix_len, nexthop_interfaces[idx]), module_ignore_errors=True)
    else:
        vlan_host_map = defaultdict(dict)
        for idx in range(len(nexthop_addrs)):
            mac = ptfadapter.dataplane.get_mac(0, int(get_intf_by_sub_intf(nexthop_interfaces[idx]))).replace(':', '')
            vlan_host_map[nexthop_interfaces[idx]][nexthop_addrs[idx]] = mac
        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 add_ipaddr(ptfadapter, ptfhost, nexthop_addrs, prefix_len, nexthop_interfaces, ipv6=False):
    if ipv6:
        for idx in range(len(nexthop_addrs)):
            ptfhost.shell('ip -6 addr add {}/{} dev eth{}'.format(nexthop_addrs[idx], prefix_len, nexthop_interfaces[idx]), module_ignore_errors=True)
    else:
        vlan_host_map = defaultdict(dict)
        for idx in range(len(nexthop_addrs)):
            mac = ptfadapter.dataplane.get_mac(0, int(get_intf_by_sub_intf(nexthop_interfaces[idx]))).replace(':', )
            vlan_host_map[nexthop_interfaces[idx]][nexthop_addrs[idx]] = mac
        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')