From aae05fe3683a640b022f775f1100060fc51cb8bd Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Wed, 27 Jul 2016 00:54:48 +0200
Subject: [PATCH] netifd: update to latest version from LEDE

---
 ...6-netifd-update-to-latest-git-master.patch | 182 ------------------
 ...d-update-to-latest-version-from-LEDE.patch | 102 ++++++++++
 2 files changed, 102 insertions(+), 182 deletions(-)
 delete mode 100644 patches/openwrt/0016-netifd-update-to-latest-git-master.patch
 create mode 100644 patches/openwrt/0016-netifd-update-to-latest-version-from-LEDE.patch

diff --git a/patches/openwrt/0016-netifd-update-to-latest-git-master.patch b/patches/openwrt/0016-netifd-update-to-latest-git-master.patch
deleted file mode 100644
index 8128cfb0e..000000000
--- a/patches/openwrt/0016-netifd-update-to-latest-git-master.patch
+++ /dev/null
@@ -1,182 +0,0 @@
-From: Matthias Schiffer <mschiffer@universe-factory.net>
-Date: Wed, 9 Mar 2016 06:46:44 +0100
-Subject: netifd: update to latest git master
-
-diff --git a/package/network/config/netifd/Makefile b/package/network/config/netifd/Makefile
-index 619024b..84a4592 100644
---- a/package/network/config/netifd/Makefile
-+++ b/package/network/config/netifd/Makefile
-@@ -1,13 +1,13 @@
- include $(TOPDIR)/rules.mk
- 
- PKG_NAME:=netifd
--PKG_VERSION:=2015-12-16
-+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:=245527193e90906451be35c2b8e972b8712ea6ab
-+PKG_SOURCE_VERSION:=6fd6be6b7f3fc4883fdc464fcbcb2b5e8d8e8174
- PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
- PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
- # PKG_MIRROR_MD5SUM:=
-diff --git a/package/network/config/netifd/files/etc/init.d/network b/package/network/config/netifd/files/etc/init.d/network
-index 542fc08..bdadbbc 100755
---- a/package/network/config/netifd/files/etc/init.d/network
-+++ b/package/network/config/netifd/files/etc/init.d/network
-@@ -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
- }
-diff --git a/package/network/config/netifd/files/sbin/ifup b/package/network/config/netifd/files/sbin/ifup
-index af3aaa8..5515b91 100755
---- a/package/network/config/netifd/files/sbin/ifup
-+++ b/package/network/config/netifd/files/sbin/ifup
-@@ -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/0001-Revert-device-Don-t-process-link-events-anymore-in-d.patch b/package/network/config/netifd/patches/0001-Revert-device-Don-t-process-link-events-anymore-in-d.patch
-new file mode 100644
-index 0000000..312964f
---- /dev/null
-+++ b/package/network/config/netifd/patches/0001-Revert-device-Don-t-process-link-events-anymore-in-d.patch
-@@ -0,0 +1,121 @@
-+From e0f19fdae88f3ef505e22533915f8328f4793980 Mon Sep 17 00:00:00 2001
-+Message-Id: <e0f19fdae88f3ef505e22533915f8328f4793980.1462479663.git.mschiffer@universe-factory.net>
-+From: Matthias Schiffer <mschiffer@universe-factory.net>
-+Date: Thu, 5 May 2016 21:49:33 +0200
-+Subject: [PATCH] Revert "device: Don't process link events anymore in device
-+ user specific callback handlers"
-+
-+This reverts commit 4902ba2999dec02e82066d70ab6096b852a33007.
-+---
-+ device.h       | 2 ++
-+ macvlan.c      | 8 ++++++++
-+ system-linux.c | 2 +-
-+ vlan.c         | 6 ++++++
-+ vlandev.c      | 8 ++++++++
-+ 5 files changed, 25 insertions(+), 1 deletion(-)
-+
-+diff --git a/device.h b/device.h
-+index ac77cfb..ef1c608 100644
-+--- a/device.h
-++++ b/device.h
-+@@ -59,6 +59,8 @@ struct device_type {
-+ 	struct list_head list;
-+ 	const char *name;
-+ 
-++	bool keep_link_status;
-++
-+ 	const struct uci_blob_param_list *config_params;
-+ 
-+ 	struct device *(*create)(const char *name, struct blob_attr *attr);
-+diff --git a/macvlan.c b/macvlan.c
-+index a0f11ae..051fe05 100644
-+--- a/macvlan.c
-++++ b/macvlan.c
-+@@ -72,6 +72,12 @@ macvlan_base_cb(struct device_user *dev, enum device_event ev)
-+ 	case DEV_EVENT_REMOVE:
-+ 		device_set_present(&mvdev->dev, false);
-+ 		break;
-++	case DEV_EVENT_LINK_UP:
-++		device_set_link(&mvdev->dev, true);
-++		break;
-++	case DEV_EVENT_LINK_DOWN:
-++		device_set_link(&mvdev->dev, false);
-++		break;
-+ 	default:
-+ 		return;
-+ 	}
-+@@ -255,6 +261,8 @@ macvlan_create(const char *name, struct blob_attr *attr)
-+ const struct device_type macvlan_device_type = {
-+ 	.name = "MAC VLAN",
-+ 	.config_params = &macvlan_attr_list,
-++	.keep_link_status = true,
-++
-+ 	.create = macvlan_create,
-+ 	.config_init = macvlan_config_init,
-+ 	.reload = macvlan_reload,
-+diff --git a/system-linux.c b/system-linux.c
-+index 351a994..794c1dd 100644
-+--- a/system-linux.c
-++++ b/system-linux.c
-+@@ -464,7 +464,7 @@ static int cb_rtnl_event(struct nl_msg *msg, void *arg)
-+ 		goto out;
-+ 
-+ 	struct device *dev = device_get(nla_data(nla[IFLA_IFNAME]), false);
-+-	if (!dev)
-++	if (!dev || dev->type->keep_link_status)
-+ 		goto out;
-+ 
-+ 	if (!system_get_dev_sysctl("/sys/class/net/%s/carrier", dev->ifname, buf, sizeof(buf)))
-+diff --git a/vlan.c b/vlan.c
-+index ac434ce..8d93799 100644
-+--- a/vlan.c
-++++ b/vlan.c
-+@@ -79,6 +79,11 @@ static void vlan_dev_cb(struct device_user *dep, enum device_event ev)
-+ 	case DEV_EVENT_REMOVE:
-+ 		device_set_present(&vldev->dev, new_state);
-+ 		break;
-++	case DEV_EVENT_LINK_UP:
-++		new_state = true;
-++	case DEV_EVENT_LINK_DOWN:
-++		device_set_link(&vldev->dev, new_state);
-++		break;
-+ 	case DEV_EVENT_UPDATE_IFNAME:
-+ 		vlan_dev_set_name(vldev, dep->dev);
-+ 		device_broadcast_event(&vldev->dev, ev);
-+@@ -97,6 +102,7 @@ static struct device *get_vlan_device(struct device *dev, int id, bool create)
-+ 	static const struct device_type vlan_type = {
-+ 		.name = "VLAN",
-+ 		.config_params = &device_attr_list,
-++		.keep_link_status = true,
-+ 		.free = free_vlan_if,
-+ 	};
-+ 	struct vlan_device *vldev;
-+diff --git a/vlandev.c b/vlandev.c
-+index b93527c..884e6ef 100644
-+--- a/vlandev.c
-++++ b/vlandev.c
-+@@ -63,6 +63,12 @@ vlandev_base_cb(struct device_user *dev, enum device_event ev)
-+ 	case DEV_EVENT_REMOVE:
-+ 		device_set_present(&mvdev->dev, false);
-+ 		break;
-++	case DEV_EVENT_LINK_UP:
-++		device_set_link(&mvdev->dev, true);
-++		break;
-++	case DEV_EVENT_LINK_DOWN:
-++		device_set_link(&mvdev->dev, false);
-++		break;
-+ 	default:
-+ 		return;
-+ 	}
-+@@ -243,6 +249,8 @@ vlandev_create(const char *name, struct blob_attr *attr)
-+ const struct device_type vlandev_device_type = {
-+ 	.name = "VLANDEV",
-+ 	.config_params = &vlandev_attr_list,
-++	.keep_link_status = true,
-++
-+ 	.create = vlandev_create,
-+ 	.config_init = vlandev_config_init,
-+ 	.reload = vlandev_reload,
-+-- 
-+2.8.2
-+
diff --git a/patches/openwrt/0016-netifd-update-to-latest-version-from-LEDE.patch b/patches/openwrt/0016-netifd-update-to-latest-version-from-LEDE.patch
new file mode 100644
index 000000000..85a35461e
--- /dev/null
+++ b/patches/openwrt/0016-netifd-update-to-latest-version-from-LEDE.patch
@@ -0,0 +1,102 @@
+From: Matthias Schiffer <mschiffer@universe-factory.net>
+Date: Wed, 9 Mar 2016 06:46:44 +0100
+Subject: netifd: update to latest version from LEDE
+
+diff --git a/package/network/config/netifd/Makefile b/package/network/config/netifd/Makefile
+index 619024b..d9c63eb 100644
+--- a/package/network/config/netifd/Makefile
++++ b/package/network/config/netifd/Makefile
+@@ -1,15 +1,15 @@
+ include $(TOPDIR)/rules.mk
+ 
+ PKG_NAME:=netifd
+-PKG_VERSION:=2015-12-16
++PKG_VERSION:=2016-06-06
+ PKG_RELEASE=$(PKG_SOURCE_VERSION)
+ 
+ PKG_SOURCE_PROTO:=git
+-PKG_SOURCE_URL:=http://git.openwrt.org/project/netifd.git
++PKG_SOURCE_URL=$(LEDE_GIT)/project/netifd.git
+ PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+-PKG_SOURCE_VERSION:=245527193e90906451be35c2b8e972b8712ea6ab
++PKG_SOURCE_VERSION:=99e6dc68bbac5a57a0ebca810a9dc36e38667821
+ 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
+ 
+diff --git a/package/network/config/netifd/files/etc/init.d/network b/package/network/config/netifd/files/etc/init.d/network
+index 542fc08..bdadbbc 100755
+--- a/package/network/config/netifd/files/etc/init.d/network
++++ b/package/network/config/netifd/files/etc/init.d/network
+@@ -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
+ }
+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 0e88af9..abfdaaf 100755
+--- a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
++++ b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
+@@ -12,6 +12,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_string 'reqopts:list(string)'
+ 	proto_config_add_string iface6rd
+ 	proto_config_add_string sendopts
+@@ -26,8 +27,8 @@ proto_dhcp_setup() {
+ 	local config="$1"
+ 	local iface="$2"
+ 
+-	local ipaddr hostname clientid vendorid broadcast reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes
+-	json_get_vars ipaddr hostname clientid vendorid broadcast reqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes
++	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
+@@ -39,6 +40,7 @@ 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"
+@@ -54,9 +56,9 @@ proto_dhcp_setup() {
+ 		-s /lib/netifd/dhcp.script \
+ 		-f -t 0 -i "$iface" \
+ 		${ipaddr:+-r $ipaddr} \
+-		${hostname:+-H $hostname} \
+-		${vendorid:+-V $vendorid} \
+-		$clientid $broadcast $dhcpopts
++		${hostname:+-H "$hostname"} \
++		${vendorid:+-V "$vendorid"} \
++		$clientid $broadcast $release $dhcpopts
+ }
+ 
+ proto_dhcp_renew() {
+diff --git a/package/network/config/netifd/files/sbin/ifup b/package/network/config/netifd/files/sbin/ifup
+index af3aaa8..5515b91 100755
+--- a/package/network/config/netifd/files/sbin/ifup
++++ b/package/network/config/netifd/files/sbin/ifup
+@@ -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
-- 
GitLab