Filters given options and outputs valid settings for a
    network interface.

def _parse_settings_eth(opts, iface_type, enabled, iface):
    '''
    Filters given options and outputs valid settings for a
    network interface.
    '''
    result = {'name': iface}
    if 'proto' in opts:
        valid = ['none', 'bootp', 'dhcp']
        if opts['proto'] in valid:
            result['proto'] = opts['proto']
        else:
            _raise_error_iface(iface, opts['proto'], valid)

    if 'dns' in opts:
        result['dns'] = opts['dns']
        result['peerdns'] = 'yes'

    if 'mtu' in opts:
        try:
            result['mtu'] = int(opts['mtu'])
        except ValueError:
            _raise_error_iface(iface, 'mtu', ['integer'])

    if iface_type not in ['bridge']:
        ethtool = _parse_ethtool_opts(opts, iface)
        if ethtool:
            result['ethtool'] = ethtool

    if iface_type == 'slave':
        result['proto'] = 'none'

    if iface_type == 'bond':
        bonding = _parse_settings_bond(opts, iface)
        if bonding:
            result['bonding'] = bonding
            result['devtype'] = "Bond"

    if iface_type == 'vlan':
        vlan = _parse_settings_vlan(opts, iface)
        if vlan:
            result['devtype'] = "Vlan"
            for opt in vlan:
                result[opt] = opts[opt]

    if iface_type not in ['bond', 'vlan', 'bridge', 'ipip']:
        auto_addr = False
        if 'addr' in opts:
            if salt.utils.validate.net.mac(opts['addr']):
                result['addr'] = opts['addr']
            elif opts['addr'] == 'auto':
                auto_addr = True
            elif opts['addr'] != 'none':
                _raise_error_iface(iface, opts['addr'], ['AA:BB:CC:DD:EE:FF', 'auto', 'none'])
        else:
            auto_addr = True

        if auto_addr:
            # If interface type is slave for bond, not setting hwaddr
            if iface_type != 'slave':
                ifaces = __salt__['network.interfaces']()
                if iface in ifaces and 'hwaddr' in ifaces[iface]:
                    result['addr'] = ifaces[iface]['hwaddr']
    if iface_type == 'eth':
        result['devtype'] = 'Ethernet'
    if iface_type == 'bridge':
        result['devtype'] = 'Bridge'
        bypassfirewall = True
        valid = _CONFIG_TRUE + _CONFIG_FALSE
        for opt in ['bypassfirewall']:
            if opt in opts:
                if opts[opt] in _CONFIG_TRUE:
                    bypassfirewall = True
                elif opts[opt] in _CONFIG_FALSE:
                    bypassfirewall = False
                else:
                    _raise_error_iface(iface, opts[opt], valid)

        bridgectls = [
            'net.bridge.bridge-nf-call-ip6tables',
            'net.bridge.bridge-nf-call-iptables',
            'net.bridge.bridge-nf-call-arptables',
            ]

        if bypassfirewall:
            sysctl_value = 0
        else:
            sysctl_value = 1

        for sysctl in bridgectls:
            try:
                __salt__['sysctl.persist'](sysctl, sysctl_value)
            except CommandExecutionError:
                log.warning('Failed to set sysctl: %s', sysctl)

    else:
        if 'bridge' in opts:
            result['bridge'] = opts['bridge']

    if iface_type == 'ipip':
        result['devtype'] = 'IPIP'
        for opt in ['my_inner_ipaddr', 'my_outer_ipaddr']:
            if opt not in opts:
                _raise_error_iface(iface, opts[opt], ['1.2.3.4'])
            else:
                result[opt] = opts[opt]
    if iface_type == 'ib':
        result['devtype'] = 'InfiniBand'

    if 'prefix' in opts:
        if 'netmask' in opts:
            msg = 'Cannot use prefix and netmask together'
            log.error(msg)
            raise AttributeError(msg)
        result['prefix'] = opts['prefix']
    elif 'netmask' in opts:
        result['netmask'] = opts['netmask']

    for opt in ['ipaddr', 'master', 'srcaddr', 'delay', 'domain', 'gateway', 'uuid', 'nickname', 'zone']:
        if opt in opts:
            result[opt] = opts[opt]

    for opt in ['ipv6addr', 'ipv6gateway']:
        if opt in opts:
            result[opt] = opts[opt]

    if 'ipaddrs' in opts:
        result['ipaddrs'] = []
        for opt in opts['ipaddrs']:
            if salt.utils.validate.net.ipv4_addr(opt):
                ip, prefix = [i.strip() for i in opt.split('/')]
                result['ipaddrs'].append({'ipaddr': ip, 'prefix': prefix})
            else:
                msg = 'ipv4 CIDR is invalid'
                log.error(msg)
                raise AttributeError(msg)

    if 'ipv6addrs' in opts:
        for opt in opts['ipv6addrs']:
            if not salt.utils.validate.net.ipv6_addr(opt):
                msg = 'ipv6 CIDR is invalid'
                log.error(msg)
                raise AttributeError(msg)
            result['ipv6addrs'] = opts['ipv6addrs']

    if 'enable_ipv6' in opts:
        result['enable_ipv6'] = opts['enable_ipv6']

    valid = _CONFIG_TRUE + _CONFIG_FALSE
    for opt in ['onparent', 'peerdns', 'peerroutes', 'slave', 'vlan', 'defroute', 'stp', 'ipv6_peerdns',
                'ipv6_defroute', 'ipv6_peerroutes', 'ipv6_autoconf', 'ipv4_failure_fatal', 'dhcpv6c']:
        if opt in opts:
            if opts[opt] in _CONFIG_TRUE:
                result[opt] = 'yes'
            elif opts[opt] in _CONFIG_FALSE:
                result[opt] = 'no'
            else:
                _raise_error_iface(iface, opts[opt], valid)

    if 'onboot' in opts:
        log.warning(
            'The \'onboot\' option is controlled by the \'enabled\' option. '
            'Interface: %s Enabled: %s', iface, enabled
        )

    if enabled:
        result['onboot'] = 'yes'
    else:
        result['onboot'] = 'no'

    # If the interface is defined then we want to always take
    # control away from non-root users; unless the administrator
    # wants to allow non-root users to control the device.
    if 'userctl' in opts:
        if opts['userctl'] in _CONFIG_TRUE:
            result['userctl'] = 'yes'
        elif opts['userctl'] in _CONFIG_FALSE:
            result['userctl'] = 'no'
        else:
            _raise_error_iface(iface, opts['userctl'], valid)
    else:
        result['userctl'] = 'no'

    # This vlan is in opts, and should be only used in range interface
    # will affect jinja template for interface generating
    if 'vlan' in opts:
        if opts['vlan'] in _CONFIG_TRUE:
            result['vlan'] = 'yes'
        elif opts['vlan'] in _CONFIG_FALSE:
            result['vlan'] = 'no'
        else:
            _raise_error_iface(iface, opts['vlan'], valid)

    if 'arpcheck' in opts:
        if opts['arpcheck'] in _CONFIG_FALSE:
            result['arpcheck'] = 'no'

    if 'ipaddr_start' in opts:
        result['ipaddr_start'] = opts['ipaddr_start']

    if 'ipaddr_end' in opts:
        result['ipaddr_end'] = opts['ipaddr_end']

    if 'clonenum_start' in opts:
        result['clonenum_start'] = opts['clonenum_start']

    # If NetworkManager is available, we can control whether we use
    # it or not
    if 'nm_controlled' in opts:
        if opts['nm_controlled'] in _CONFIG_TRUE:
            result['nm_controlled'] = 'yes'
        elif opts['nm_controlled'] in _CONFIG_FALSE:
            result['nm_controlled'] = 'no'
        else:
            _raise_error_iface(iface, opts['nm_controlled'], valid)
    else:
        result['nm_controlled'] = 'no'

    return result