diff --git a/package/network/config/netifd/Makefile b/package/network/config/netifd/Makefile index 31640c80cd..ed35719aaa 100644 --- a/package/network/config/netifd/Makefile +++ b/package/network/config/netifd/Makefile @@ -5,9 +5,9 @@ PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/netifd.git -PKG_SOURCE_DATE:=2019-08-05 -PKG_SOURCE_VERSION:=5e02f94411b06f192fb2a7d9be9abde3549153a8 -PKG_MIRROR_HASH:=96e158584c605e96aceb3ce7e8ad8faa8e774ffd67d59558b2d6c2ff49d0f1a5 +PKG_SOURCE_DATE:=2020-12-13 +PKG_SOURCE_VERSION:=458b1a7e9473c150a40cae5d8be174f4bb03bd39 +PKG_MIRROR_HASH:=424aefb55aedebfcffd540a2c02a42aeb574b7ebb1a6b546ca9965d9280d82e5 PKG_MAINTAINER:=Felix Fietkau PKG_LICENSE:=GPL-2.0 diff --git a/package/network/config/netifd/files/etc/hotplug.d/net/20-smp-tune b/package/network/config/netifd/files/etc/hotplug.d/net/20-smp-packet-steering similarity index 72% rename from package/network/config/netifd/files/etc/hotplug.d/net/20-smp-tune rename to package/network/config/netifd/files/etc/hotplug.d/net/20-smp-packet-steering index ab9a90418e..8a86bf75f6 100644 --- a/package/network/config/netifd/files/etc/hotplug.d/net/20-smp-tune +++ b/package/network/config/netifd/files/etc/hotplug.d/net/20-smp-packet-steering @@ -14,7 +14,7 @@ find_irq_cpu() { [ -n "$match" ] && { set -- $match shift - for cur in `seq 1 $NPROCS`; do + for cur in $(seq 1 $NPROCS); do [ "$1" -gt 0 ] && { cpu=$(($cur - 1)) break @@ -34,8 +34,8 @@ set_hex_val() { echo "$val" > "$file" } -default_ps="$(uci get "network.@globals[0].default_ps")" -[ -n "$default_ps" -a "$default_ps" != 1 ] && exit 0 +packet_steering="$(uci get "network.@globals[0].packet_steering")" +[ "$packet_steering" != 1 ] && exit 0 exec 512>/var/lock/smp_tune.lock flock 512 || exit 1 @@ -52,16 +52,16 @@ for dev in /sys/class/net/*; do irq_cpu="$(find_irq_cpu "$device")" irq_cpu_mask="$((1 << $irq_cpu))" - for q in ${dev}/queues/rx-*; do - set_hex_val "$q/rps_cpus" "$(($PROC_MASK & ~$irq_cpu_mask))" + for q in ${dev}/queues/tx-*; do + set_hex_val "$q/xps_cpus" "$PROC_MASK" done - ntxq="$(ls -d ${dev}/queues/tx-* | wc -l)" + # ignore dsa slave ports for RPS + subsys="$(readlink "${dev}/device/subsystem")" + subsys="$(basename "$subsys")" + [ "$subsys" = "mdio_bus" ] && continue - idx=$(($irq_cpu + 1)) - for q in ${dev}/queues/tx-*; do - set_hex_val "$q/xps_cpus" "$((1 << $idx))" - let "idx = idx + 1" - [ "$idx" -ge "$NPROCS" ] && idx=0 + for q in ${dev}/queues/rx-*; do + set_hex_val "$q/rps_cpus" "$PROC_MASK" done done diff --git a/package/network/config/netifd/files/etc/init.d/network b/package/network/config/netifd/files/etc/init.d/network index 2321a309a5..dc208c4ce0 100755 --- a/package/network/config/netifd/files/etc/init.d/network +++ b/package/network/config/netifd/files/etc/init.d/network @@ -40,11 +40,6 @@ stop_service() { sleep 1 } -service_running() { - ubus -t 30 wait_for network.interface - /sbin/wifi reload_legacy -} - validate_atm_bridge_section() { uci_validate_section network "atm-bridge" "${1}" \ diff --git a/package/network/config/netifd/files/etc/uci-defaults/14_migrate-dhcp-release b/package/network/config/netifd/files/etc/uci-defaults/14_migrate-dhcp-release new file mode 100644 index 0000000000..f1b384eecc --- /dev/null +++ b/package/network/config/netifd/files/etc/uci-defaults/14_migrate-dhcp-release @@ -0,0 +1,23 @@ +. /lib/functions.sh + +migrate_release() { + local config="$1" + local proto + local release + + config_get proto "$config" proto + config_get release "$config" release + + [ "$proto" = "dhcp" ] && [ -n "$release" ] && { + norelease="$((!$release))" + uci_set network "$config" norelease "$norelease" + uci_remove network "$config" release + } + +} + +config_load network +config_foreach migrate_release interface +uci commit network + +exit 0 diff --git a/package/network/config/netifd/files/lib/netifd/dhcp.script b/package/network/config/netifd/files/lib/netifd/dhcp.script index 00604f40e7..6585b641d6 100755 --- a/package/network/config/netifd/files/lib/netifd/dhcp.script +++ b/package/network/config/netifd/files/lib/netifd/dhcp.script @@ -46,10 +46,16 @@ setup_interface () { proto_add_dns_search "$i" done + # TODO: Deprecate timesvr in favor of timesrv + if [ -n "$timesvr" -a -z "$timesrv" ]; then + timesrv="$timesvr" + echo "Environment variable 'timesvr' will be deprecated; use 'timesrv' instead." + fi + proto_add_data [ -n "$ZONE" ] && json_add_string zone "$ZONE" [ -n "$ntpsrv" ] && json_add_string ntpserver "$ntpsrv" - [ -n "$timesvr" ] && json_add_string timeserver "$timesvr" + [ -n "$timesrv" ] && json_add_string timeserver "$timesrv" [ -n "$hostname" ] && json_add_string hostname "$hostname" [ -n "$message" ] && json_add_string message "$message" [ -n "$timezone" ] && json_add_int timezone "$timezone" diff --git a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh index 0d06eba06e..3034b2ba68 100755 --- a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh +++ b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh @@ -14,7 +14,7 @@ proto_dhcp_init_config() { proto_config_add_string clientid proto_config_add_string vendorid proto_config_add_boolean 'broadcast:bool' - proto_config_add_boolean 'release:bool' + proto_config_add_boolean 'norelease:bool' proto_config_add_string 'reqopts:list(string)' proto_config_add_boolean 'defaultreqopts:bool' proto_config_add_string iface6rd @@ -35,8 +35,8 @@ proto_dhcp_setup() { local config="$1" local iface="$2" - local ipaddr hostname clientid vendorid broadcast release reqopts defaultreqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute - json_get_vars ipaddr hostname clientid vendorid broadcast release reqopts defaultreqopts iface6rd delegate zone6rd zone mtu6rd customroutes classlessroute + local ipaddr hostname clientid vendorid broadcast norelease reqopts defaultreqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute + json_get_vars ipaddr hostname clientid vendorid broadcast norelease reqopts defaultreqopts iface6rd delegate zone6rd zone mtu6rd customroutes classlessroute local opt dhcpopts for opt in $reqopts; do @@ -50,7 +50,7 @@ proto_dhcp_setup() { [ "$defaultreqopts" = 0 ] && defaultreqopts="-o" || defaultreqopts= [ "$broadcast" = 1 ] && broadcast="-B" || broadcast= - [ "$release" = 1 ] && release="-R" || release= + [ "$norelease" = 1 ] && norelease="" || norelease="-R" [ -n "$clientid" ] && clientid="-x 0x3d:${clientid//:/}" || clientid="-C" [ -n "$iface6rd" ] && proto_export "IFACE6RD=$iface6rd" [ "$iface6rd" != 0 -a -f /lib/netifd/proto/6rd.sh ] && append dhcpopts "-O 212" @@ -70,7 +70,7 @@ proto_dhcp_setup() { ${ipaddr:+-r $ipaddr} \ ${hostname:+-x "hostname:$hostname"} \ ${vendorid:+-V "$vendorid"} \ - $clientid $defaultreqopts $broadcast $release $dhcpopts + $clientid $defaultreqopts $broadcast $norelease $dhcpopts } proto_dhcp_renew() { diff --git a/package/network/config/netifd/files/lib/network/config.sh b/package/network/config/netifd/files/lib/network/config.sh index 0ded45edc4..4cd28e4ce1 100755 --- a/package/network/config/netifd/files/lib/network/config.sh +++ b/package/network/config/netifd/files/lib/network/config.sh @@ -6,13 +6,13 @@ find_config() { local device="$1" local ifdev ifl3dev ifobj - for ifobj in `ubus list network.interface.\*`; do + for ifobj in $(ubus list network.interface.\*); do interface="${ifobj##network.interface.}" ( json_load "$(ifstatus $interface)" json_get_var ifdev device json_get_var ifl3dev l3_device - if [[ "$device" = "$ifdev" ]] || [[ "$device" = "$ifl3dev" ]]; then + if [ "$device" = "$ifdev" ] || [ "$device" = "$ifl3dev" ]; then echo "$interface" exit 0 else diff --git a/package/network/config/netifd/files/sbin/ifup b/package/network/config/netifd/files/sbin/ifup index 5515b91f76..15be535bbf 100755 --- a/package/network/config/netifd/files/sbin/ifup +++ b/package/network/config/netifd/files/sbin/ifup @@ -37,7 +37,7 @@ done [ "$modes" = "down up" ] && ubus call network reload if [ -n "$ifup_all" ]; then - for interface in `ubus -S list 'network.interface.*'`; do + for interface in $(ubus -S list 'network.interface.*'); do if_call "${interface##network.interface.}" done [ -n "$setup_wifi" ] && /sbin/wifi up diff --git a/package/network/config/netifd/files/usr/share/udhcpc/default.script b/package/network/config/netifd/files/usr/share/udhcpc/default.script index ac765a6363..0a9eb0180e 100755 --- a/package/network/config/netifd/files/usr/share/udhcpc/default.script +++ b/package/network/config/netifd/files/usr/share/udhcpc/default.script @@ -14,8 +14,8 @@ set_classless_routes() { } setup_interface() { - echo "udhcpc: ifconfig $interface $ip netmask ${subnet:-255.255.255.0} broadcast ${broadcast:-+}" - ifconfig $interface $ip netmask ${subnet:-255.255.255.0} broadcast ${broadcast:-+} + echo "udhcpc: ip addr add $ip/${subnet:-255.255.255.0} broadcast ${broadcast:-+} dev $interface" + ip addr add $ip/${subnet:-255.255.255.0} broadcast ${broadcast:-+} dev $interface [ -n "$router" ] && [ "$router" != "0.0.0.0" ] && [ "$router" != "255.255.255.255" ] && { echo "udhcpc: setting default routers: $router" @@ -41,7 +41,7 @@ setup_interface() { applied= case "$1" in deconfig) - ifconfig "$interface" 0.0.0.0 + ip -4 addr flush dev "$interface" ;; renew) setup_interface update diff --git a/package/network/config/vxlan/Makefile b/package/network/config/vxlan/Makefile index 13fcf0c55d..97972d6d85 100644 --- a/package/network/config/vxlan/Makefile +++ b/package/network/config/vxlan/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=vxlan -PKG_RELEASE:=3 +PKG_RELEASE:=7 PKG_LICENSE:=GPL-2.0 include $(INCLUDE_DIR)/package.mk diff --git a/package/network/config/vxlan/files/vxlan.sh b/package/network/config/vxlan/files/vxlan.sh index 7b1c703955..a087c4a3ce 100755 --- a/package/network/config/vxlan/files/vxlan.sh +++ b/package/network/config/vxlan/files/vxlan.sh @@ -7,6 +7,50 @@ init_proto "$@" } +proto_vxlan_setup_peer() { + type bridge &> /dev/null || { + proto_notify_error "$cfg" "MISSING_BRIDGE_COMMAND" + exit + } + + local peer_config="$1" + + local vxlan + local lladdr + local dst + local src_vni + local vni + local port + local via + + config_get vxlan "${peer_config}" "vxlan" + config_get lladdr "${peer_config}" "lladdr" + config_get dst "${peer_config}" "dst" + config_get src_vni "${peer_config}" "src_vni" + config_get vni "${peer_config}" "vni" + config_get port "${peer_config}" "port" + config_get via "${peer_config}" "via" + + [ "$cfg" = "$vxlan" ] || { + # This peer section belongs to another device + return + } + + [ -n "${dst}" ] || { + proto_notify_error "$cfg" "MISSING_PEER_ADDRESS" + exit + } + + bridge fdb append \ + ${lladdr:-00:00:00:00:00:00} \ + dev ${cfg} \ + dst ${dst} \ + ${src_vni:+src_vni $src_vni} \ + ${vni:+vni $vni} \ + ${port:+port $port} \ + ${via:+via $via} +} + vxlan_generic_setup() { local cfg="$1" local mode="$2" @@ -15,9 +59,8 @@ vxlan_generic_setup() { local link="$cfg" - local port vid ttl tos mtu macaddr zone rxcsum txcsum - json_get_vars port vid ttl tos mtu macaddr zone rxcsum txcsum - + local port vid ttl tos mtu macaddr zone rxcsum txcsum srcportmin srcportmax ageing maxaddress learning rsc proxy l2miss l3miss gbp + json_get_vars port vid ttl tos mtu macaddr zone rxcsum txcsum srcportmin srcportmax ageing maxaddress learning rsc proxy l2miss l3miss gbp proto_init_update "$link" 1 @@ -35,9 +78,20 @@ vxlan_generic_setup() { json_add_object 'data' [ -n "$port" ] && json_add_int port "$port" [ -n "$vid" ] && json_add_int id "$vid" + [ -n "$srcportmin" ] && json_add_int srcportmin "$srcportmin" + [ -n "$srcportmax" ] && json_add_int srcportmax "$srcportmax" + [ -n "$ageing" ] && json_add_int ageing "$ageing" + [ -n "$maxaddress" ] && json_add_int maxaddress "$maxaddress" [ -n "$macaddr" ] && json_add_string macaddr "$macaddr" [ -n "$rxcsum" ] && json_add_boolean rxcsum "$rxcsum" [ -n "$txcsum" ] && json_add_boolean txcsum "$txcsum" + [ -n "$learning" ] && json_add_boolean learning "$learning" + [ -n "$rsc" ] && json_add_boolean rsc "$rsc" + [ -n "$proxy" ] && json_add_boolean proxy "$proxy" + [ -n "$l2miss" ] && json_add_boolean l2miss "$l2miss" + [ -n "$l3miss" ] && json_add_boolean l3miss "$l3miss" + [ -n "$gbp" ] && json_add_boolean gbp "$gbp" + json_close_object proto_close_tunnel @@ -47,6 +101,9 @@ vxlan_generic_setup() { proto_close_data proto_send_update "$cfg" + + config_load network + config_foreach proto_vxlan_setup_peer "vxlan_peer" } proto_vxlan_setup() { @@ -55,26 +112,13 @@ proto_vxlan_setup() { local ipaddr peeraddr json_get_vars ipaddr peeraddr tunlink - [ -z "$peeraddr" ] && { - proto_notify_error "$cfg" "MISSING_ADDRESS" - proto_block_restart "$cfg" - exit - } - ( proto_add_host_dependency "$cfg" '' "$tunlink" ) - [ -z "$ipaddr" ] && { - local wanif="$tunlink" - if [ -z "$wanif" ] && ! network_find_wan wanif; then - proto_notify_error "$cfg" "NO_WAN_LINK" - exit - fi - - if ! network_get_ipaddr ipaddr "$wanif"; then - proto_notify_error "$cfg" "NO_WAN_LINK" - exit - fi - } + case "$ipaddr" in + "auto"|"") + ipaddr="0.0.0.0" + ;; + esac vxlan_generic_setup "$cfg" 'vxlan' "$ipaddr" "$peeraddr" } @@ -85,26 +129,14 @@ proto_vxlan6_setup() { local ip6addr peer6addr json_get_vars ip6addr peer6addr tunlink - [ -z "$peer6addr" ] && { - proto_notify_error "$cfg" "MISSING_ADDRESS" - proto_block_restart "$cfg" - exit - } - ( proto_add_host_dependency "$cfg" '' "$tunlink" ) - [ -z "$ip6addr" ] && { - local wanif="$tunlink" - if [ -z "$wanif" ] && ! network_find_wan6 wanif; then - proto_notify_error "$cfg" "NO_WAN_LINK" - exit - fi - - if ! network_get_ipaddr6 ip6addr "$wanif"; then - proto_notify_error "$cfg" "NO_WAN_LINK" - exit - fi - } + case "$ip6addr" in + "auto"|"") + # ensure tunnel via ipv6 + ip6addr="::" + ;; + esac vxlan_generic_setup "$cfg" 'vxlan6' "$ip6addr" "$peer6addr" } @@ -129,9 +161,20 @@ vxlan_generic_init_config() { proto_config_add_int "ttl" proto_config_add_int "tos" proto_config_add_int "mtu" + proto_config_add_int "srcportmin" + proto_config_add_int "srcportmax" + proto_config_add_int "ageing" + proto_config_add_int "maxaddress" proto_config_add_boolean "rxcsum" proto_config_add_boolean "txcsum" + proto_config_add_boolean "learning" + proto_config_add_boolean "rsc" + proto_config_add_boolean "proxy" + proto_config_add_boolean "l2miss" + proto_config_add_boolean "l3miss" + proto_config_add_boolean "gbp" proto_config_add_string "macaddr" + } proto_vxlan_init_config() {