Adds an interface record into Zebra protocol service database.

    The arguments are similar to "ip link add" command of iproute2.

    :param session: Session instance connecting to database.
    :param name: Name of interface.
    :param type_: Type of interface. 'loopback' or 'ethernet'.
    :param lladdr: Link layer address. Mostly MAC address.
    :return: Instance of added record or already existing record.

def ip_link_add(session, name, type_='loopback', lladdr='00:00:00:00:00:00'):
    """
    Adds an interface record into Zebra protocol service database.

    The arguments are similar to "ip link add" command of iproute2.

    :param session: Session instance connecting to database.
    :param name: Name of interface.
    :param type_: Type of interface. 'loopback' or 'ethernet'.
    :param lladdr: Link layer address. Mostly MAC address.
    :return: Instance of added record or already existing record.
    """
    intf = ip_link_show(session, ifname=name)
    if intf:
        LOG.debug('Interface "%s" already exists: %s', intf.ifname, intf)
        return intf

    if type_ == 'ethernet':
        intf = Interface(
            ifname=name,
            flags=DEFAULT_ETH_FLAGS,
            ifmtu=DEFAULT_ETH_MTU,
            ifmtu6=DEFAULT_ETH_MTU,
            hw_addr=lladdr)
    else:  # type_ == 'loopback':
        intf = Interface(
            ifname=name,
            inet='127.0.0.1/8',
            inet6='::1/128')

    session.add(intf)

    return intf