package/netifd: update to latest version. add support for linux kernel 2.6.32.71
authoracoul <alex@ozo.com>
Wed, 20 Jul 2016 19:23:14 +0000 (22:23 +0300)
committeracoul <alex@ozo.com>
Wed, 20 Jul 2016 19:23:14 +0000 (22:23 +0300)
package/network/config/netifd/Makefile
package/network/config/netifd/files/etc/init.d/network
package/network/config/netifd/files/lib/netifd/dhcp.script
package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
package/network/config/netifd/files/sbin/ifup
package/network/config/netifd/patches/001-musl_af_inet_include.patch [deleted file]
package/network/config/netifd/patches/005-openat.patch [deleted file]
package/network/config/netifd/patches/100-2_6_32.patch [new file with mode: 0644]

index be0114f4557b6c0af274bab5abc8f9e1fc8ad644..514eedd885d2d93cb5218a6684e29a25f82fd704 100644 (file)
@@ -1,19 +1,19 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=netifd
-PKG_VERSION:=2014-09-08.1
+PKG_VERSION:=2016-03-31
 PKG_RELEASE=$(PKG_SOURCE_VERSION)
 
 PKG_SOURCE_PROTO:=git
-PKG_SOURCE_URL:=http://git.openwrt.org/project/netifd.git
+PKG_SOURCE_URL=$(OPENWRT_GIT)/project/netifd.git
 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
-PKG_SOURCE_VERSION:=46c569989f984226916fec28dd8ef152a664043e
+PKG_SOURCE_VERSION:=39d9ceeb96162a83a3f5fa63e6aaa1ccb38caa62
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
-PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
 # PKG_MIRROR_MD5SUM:=
 # CMAKE_INSTALL:=1
 
-PKG_LICENSE:=GPLv2
+PKG_LICENSE:=GPL-2.0
 PKG_LICENSE_FILES:=
 
 PKG_BUILD_PARALLEL:=1
index 1d8a5b34efe132445a32f1fa7676955890b76025..bdadbbce6db6f9383a0e2c7fab25e7f5d8823091 100755 (executable)
@@ -21,7 +21,6 @@ start_service() {
        procd_set_param watch network.interface
        [ -e /proc/sys/kernel/core_pattern ] && {
                procd_set_param limits core="unlimited"
-               echo '/tmp/%e.%p.%s.%t.core' > /proc/sys/kernel/core_pattern
        }
        procd_close_instance
 }
@@ -32,8 +31,9 @@ reload_service() {
        /sbin/wifi reload_legacy
 }
 
-stop_service() {
+stop() {
        /sbin/wifi down
+       procd_kill network ''
 }
 
 service_running() {
@@ -147,5 +147,5 @@ restart() {
 
 shutdown() {
        ifdown -a
-       stop
+       sleep 1
 }
index 593fb93e1ddfa3589b241e5cd3c2739f291fc007..b3a61e27509061f9d6aa849deb45130f88a12161 100755 (executable)
@@ -6,9 +6,8 @@
 
 set_classless_routes() {
        local max=128
-       local type
        while [ -n "$1" -a -n "$2" -a $max -gt 0 ]; do
-               proto_add_ipv4_route "${1%%/*}" "${1##*/}" "$2"
+               proto_add_ipv4_route "${1%%/*}" "${1##*/}" "$2" "$ip"
                max=$(($max-1))
                shift 2
        done
@@ -20,7 +19,12 @@ setup_interface () {
        # TODO: apply $broadcast
 
        for i in $router; do
-               proto_add_ipv4_route 0.0.0.0 0 "$i"
+               proto_add_ipv4_route "$i" 32 "" "$ip"
+               proto_add_ipv4_route 0.0.0.0 0 "$i" "$ip"
+
+               for r in $CUSTOMROUTES; do
+                       proto_add_ipv4_route "${r%%/*}" "${r##*/}" "$i" "$ip"
+               done
        done
 
        # CIDR STATIC ROUTES (rfc3442)
@@ -35,7 +39,13 @@ setup_interface () {
        done
 
        proto_add_data
-       [ -n "$ZONE" ] && json_add_string zone "$ZONE"
+       [ -n "$ZONE" ]     && json_add_string zone "$ZONE"
+       [ -n "$ntpsrv" ]   && json_add_string ntpserver "$ntpsrv"
+       [ -n "$timesvr" ]  && json_add_string timeserver "$timesvr"
+       [ -n "$hostname" ] && json_add_string hostname "$hostname"
+       [ -n "$message" ]  && json_add_string message "$message"
+       [ -n "$timezone" ] && json_add_int timezone "$timezone"
+       [ -n "$lease" ]    && json_add_int leasetime "$lease"
        proto_close_data
 
        proto_send_update "$INTERFACE"
@@ -51,7 +61,7 @@ setup_interface () {
                local ip6rdbr="${ip6rd%% *}"
 
                [ -n "$ZONE" ] || ZONE=$(fw3 -q network $INTERFACE)
-               [ -z "$IFACE6RD" -o "$IFACE6RD" = 1 ] && IFACE6RD=${INTERFACE}_6rd
+               [ -z "$IFACE6RD" -o "$IFACE6RD" = 1 ] && IFACE6RD=${INTERFACE}_6
 
                json_init
                json_add_string name "$IFACE6RD"
@@ -65,16 +75,11 @@ setup_interface () {
                [ -n "$IFACE6RD_DELEGATE" ] && json_add_boolean delegate "$IFACE6RD_DELEGATE"
                [ -n "$ZONE6RD" ] || ZONE6RD=$ZONE
                [ -n "$ZONE6RD" ] && json_add_string zone "$ZONE6RD"
+               [ -n "$MTU6RD" ] && json_add_string mtu "$MTU6RD"
                json_close_object
 
                ubus call network add_dynamic "$(json_dump)"
        fi
-
-       # TODO
-       # [ -n "$ntpsrv" ] &&   change_state network "$ifc" lease_ntpsrv "$ntpsrv"
-       # [ -n "$timesvr" ] &&  change_state network "$ifc" lease_timesrv "$timesvr"
-       # [ -n "$hostname" ] && change_state network "$ifc" lease_hostname "$hostname"
-       # [ -n "$timezone" ] &&         change_state network "$ifc" lease_timezone "$timezone"
 }
 
 deconfig_interface() {
@@ -92,6 +97,6 @@ case "$1" in
 esac
 
 # user rules
-[ -f /etc/udhcpc.user ] && . /etc/udhcpc.user
+[ -f /etc/udhcpc.user ] && . /etc/udhcpc.user "$@"
 
 exit 0
index 406746067598d01065452ab687da1733ba829763..7f4af25329607360c9a69dcc31976e7f1e89a2aa 100755 (executable)
@@ -12,20 +12,23 @@ 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_string 'reqopts:list(string)'
        proto_config_add_string iface6rd
        proto_config_add_string sendopts
        proto_config_add_boolean delegate
        proto_config_add_string zone6rd
        proto_config_add_string zone
+       proto_config_add_string mtu6rd
+       proto_config_add_string customroutes
 }
 
 proto_dhcp_setup() {
        local config="$1"
        local iface="$2"
 
-       local ipaddr hostname clientid vendorid broadcast reqopts iface6rd sendopts delegate zone6rd zone
-       json_get_vars ipaddr hostname clientid vendorid broadcast reqopts iface6rd sendopts delegate zone6rd zone
+       local ipaddr hostname clientid vendorid broadcast release reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes
+       json_get_vars ipaddr hostname clientid vendorid broadcast release reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes
 
        local opt dhcpopts
        for opt in $reqopts; do
@@ -37,22 +40,25 @@ proto_dhcp_setup() {
        done
 
        [ "$broadcast" = 1 ] && broadcast="-B" || broadcast=
+       [ "$release" = 1 ] && release="-R" || release=
        [ -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"
        [ -n "$zone6rd" ] && proto_export "ZONE6RD=$zone6rd"
        [ -n "$zone" ] && proto_export "ZONE=$zone"
+       [ -n "$mtu6rd" ] && proto_export "MTU6RD=$mtu6rd"
+       [ -n "$customroutes" ] && proto_export "CUSTOMROUTES=$customroutes"
        [ "$delegate" = "0" ] && proto_export "IFACE6RD_DELEGATE=0"
 
        proto_export "INTERFACE=$config"
        proto_run_command "$config" udhcpc \
                -p /var/run/udhcpc-$iface.pid \
                -s /lib/netifd/dhcp.script \
-               -f -t 0 -i "$iface" \
+               -f -R -t 0 -i "$iface" \
                ${ipaddr:+-r $ipaddr} \
                ${hostname:+-H $hostname} \
                ${vendorid:+-V $vendorid} \
-               $clientid $broadcast $dhcpopts
+               $clientid $broadcast $release $dhcpopts
 }
 
 proto_dhcp_renew() {
index af3aaa8453ce93f52c2b89e743f43f9c509ad696..5515b91f76df2b5c36d46ac4b86dfc9bdcd78b1d 100755 (executable)
@@ -67,12 +67,10 @@ if [ -n "$setup_wifi" ] && grep -sq config /etc/config/wireless; then
                fi
        }
 
-       local radio_devs
-       local network="$1"
+       network="$1"
        config_load wireless
        config_foreach find_related_radios wifi-iface
 
-       local dev
        for dev in $(echo "$radio_devs" | sort -u); do
                /sbin/wifi up "$dev"
        done
diff --git a/package/network/config/netifd/patches/001-musl_af_inet_include.patch b/package/network/config/netifd/patches/001-musl_af_inet_include.patch
deleted file mode 100644 (file)
index 510ee05..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-diff -urN netifd-2012-10-29/utils.c netifd-2012-10-29.new/utils.c
---- netifd-2012-10-29/utils.c  2012-11-23 17:15:39.000000000 +0100
-+++ netifd-2012-10-29.new/utils.c      2012-11-23 17:16:53.409244361 +0100
-@@ -17,6 +17,7 @@
- #include <arpa/inet.h>
- #include <netinet/in.h>
-+#include <sys/socket.h>
- void
- __vlist_simple_init(struct vlist_simple_tree *tree, int offset)
diff --git a/package/network/config/netifd/patches/005-openat.patch b/package/network/config/netifd/patches/005-openat.patch
deleted file mode 100644 (file)
index 6617fdf..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/system-linux.c   2016-07-12 22:51:38.000000000 +0300
-+++ b/system-linux.c   2016-07-13 11:21:26.820071423 +0300
-@@ -1103,7 +1103,7 @@ read_string_file(int dir_fd, const char
-       char *c;
-       int fd;
--      fd = openat(dir_fd, file, O_RDONLY);
-+      fd = open(file, O_RDONLY);
-       if (fd < 0)
-               return false;
diff --git a/package/network/config/netifd/patches/100-2_6_32.patch b/package/network/config/netifd/patches/100-2_6_32.patch
new file mode 100644 (file)
index 0000000..e6fca26
--- /dev/null
@@ -0,0 +1,82 @@
+--- a/system-linux.c   2016-07-20 21:00:45.002413843 +0300
++++ b/system-linux.c   2016-07-20 20:11:46.000000000 +0300
+@@ -989,6 +989,7 @@ int system_bridge_addbr(struct device *b
+       return 0;
+ }
++#ifdef CONFIG_MACVLAN
+ int system_macvlan_add(struct device *macvlan, struct device *dev, struct macvlan_config *cfg)
+ {
+       struct nl_msg *msg;
+@@ -1048,6 +1049,7 @@ nla_put_failure:
+       nlmsg_free(msg);
+       return -ENOMEM;
+ }
++#endif
+ static int system_link_del(const char *ifname)
+ {
+@@ -1067,10 +1069,12 @@ static int system_link_del(const char *i
+       return system_rtnl_call(msg);
+ }
++#ifdef CONFIG_MACVLAN
+ int system_macvlan_del(struct device *macvlan)
+ {
+       return system_link_del(macvlan->ifname);
+ }
++#endif
+ static int system_vlan(struct device *dev, int id)
+ {
+@@ -1469,7 +1473,11 @@ read_string_file(int dir_fd, const char
+       char *c;
+       int fd;
++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,33)
+       fd = openat(dir_fd, file, O_RDONLY);
++#else
++      fd = open(file, O_RDONLY);
++#endif
+       if (fd < 0)
+               return false;
+@@ -1938,8 +1946,10 @@ static int system_iprule(struct iprule *
+       if (rule->flags & IPRULE_IN)
+               nla_put(msg, FRA_IFNAME, strlen(rule->in_dev) + 1, rule->in_dev);
++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,33)
+       if (rule->flags & IPRULE_OUT)
+               nla_put(msg, FRA_OIFNAME, strlen(rule->out_dev) + 1, rule->out_dev);
++#endif
+       if (rule->flags & IPRULE_SRC)
+               nla_put(msg, FRA_SRC, alen, &rule->src_addr);
+--- a/macvlan.c        2016-07-20 20:11:46.000000000 +0300
++++ b/macvlan.c        2016-07-20 22:15:32.726092978 +0300
+@@ -81,7 +81,9 @@ static int
+ macvlan_set_down(struct macvlan_device *mvdev)
+ {
+       mvdev->set_state(&mvdev->dev, false);
++#ifdef CONFIG_MACVLAN
+       system_macvlan_del(&mvdev->dev);
++#endif
+       device_release(&mvdev->parent);
+       return 0;
+@@ -96,6 +98,7 @@ macvlan_set_up(struct macvlan_device *mv
+       if (ret < 0)
+               return ret;
++#ifdef CONFIG_MACVLAN
+       ret = system_macvlan_add(&mvdev->dev, mvdev->parent.dev, &mvdev->config);
+       if (ret < 0)
+               goto release;
+@@ -110,6 +113,7 @@ delete:
+       system_macvlan_del(&mvdev->dev);
+ release:
+       device_release(&mvdev->parent);
++#endif
+       return ret;
+ }