mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-12-20 10:51:27 +00:00
opensync: more network manager fixes
This patch will get folded into the main patch when we push to trunk. Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
parent
f2ad970ed9
commit
ed379f94f2
@ -1,3 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
/usr/opensync/tools/ovsh insert Wifi_Inet_Config enabled:=true if_name:=lan_100 if_type:=bridge inet_addr:=192.168.100.1 ip_assign_scheme:=static mtu:=1500 netmask:=255.255.255.0 network:=true vlan_id:=100
|
||||
/usr/opensync/tools/ovsh insert Wifi_Inet_Config NAT:=false enabled:=true if_name:=lan_100 if_type:=eth inet_addr:=192.168.100.1 ip_assign_scheme:=static mtu:=1500 netmask:=255.255.255.0 network:=true vlan_id:=100 parent_ifname:=lan dhcpd:="[\"map\",[[\"start\",\"100\"], [\"stop\",\"250\"], [\"lease_time\",\"1h\"]]]"
|
||||
/usr/opensync/tools/ovsh insert Wifi_Inet_Config NAT:=true enabled:=true if_name:=wan_100 if_type:=eth ip_assign_scheme:=dhcp mtu:=1500 network:=true vlan_id:=100 parent_ifname:=wan
|
||||
|
||||
ubus call osync-wm dbg_add_vif '{"radio":"radio1", "name":"test", "vid":100, "network":"lan", "ssid":"test"}'
|
||||
|
||||
@ -31,12 +31,10 @@ static void cmd_ubus_l3_dev(struct ubus_request *req,
|
||||
struct blob_attr *tb[__NET_ATTR_MAX] = { };
|
||||
char *ifname = (char *)req->priv;
|
||||
|
||||
syslog(0, "blogic %s:%s[%d]\n", __FILE__, __func__, __LINE__);
|
||||
blobmsg_parse(network_policy, __NET_ATTR_MAX, tb, blob_data(msg), blob_len(msg));
|
||||
memset(ifname, 0, IF_NAMESIZE);
|
||||
if (tb[NET_ATTR_L3_DEVICE])
|
||||
strncpy(ifname, blobmsg_get_string(tb[NET_ATTR_L3_DEVICE]), IF_NAMESIZE);
|
||||
syslog(0, "blogic %s:%s[%d]%s\n", __FILE__, __func__, __LINE__, ifname);
|
||||
}
|
||||
|
||||
int ubus_get_l3_device(const char *net, char *ifname)
|
||||
@ -44,11 +42,9 @@ int ubus_get_l3_device(const char *net, char *ifname)
|
||||
uint32_t netifd;
|
||||
char path[64];
|
||||
|
||||
syslog(0, "blogic %s:%s[%d]\n", __FILE__, __func__, __LINE__);
|
||||
snprintf(path, sizeof(path), "network.interface.%s", net);
|
||||
if (ubus_lookup_id(ubus, path, &netifd))
|
||||
return -1;
|
||||
syslog(0, "blogic %s:%s[%d]\n", __FILE__, __func__, __LINE__);
|
||||
return ubus_invoke(ubus, netifd, "status", NULL, cmd_ubus_l3_dev, ifname, 1000);
|
||||
}
|
||||
|
||||
|
||||
@ -34,12 +34,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
target_managers_config_t target_managers_config[] =
|
||||
{
|
||||
{
|
||||
.name = TARGET_MANAGER_PATH("wm"),
|
||||
.needs_plan_b = true,
|
||||
}, {
|
||||
.name = TARGET_MANAGER_PATH("nm"),
|
||||
.needs_plan_b = true,
|
||||
}, {
|
||||
// .name = TARGET_MANAGER_PATH("wm"),
|
||||
// .needs_plan_b = true,
|
||||
// }, {
|
||||
// .name = TARGET_MANAGER_PATH("nm"),
|
||||
// .needs_plan_b = true,
|
||||
// }, {
|
||||
.name = TARGET_MANAGER_PATH("cm"),
|
||||
.needs_plan_b = true,
|
||||
}, {
|
||||
|
||||
@ -238,6 +238,7 @@ static void periodic_task(void *arg)
|
||||
LOGT("periodic: reload config");
|
||||
reload_config = 0;
|
||||
uci_commit_all(uci);
|
||||
sync();
|
||||
system("reload_config");
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "target.h"
|
||||
|
||||
#include "radio.h"
|
||||
#include "phy.h"
|
||||
#include "ubus.h"
|
||||
|
||||
extern struct ev_loop *wifihal_evloop;
|
||||
@ -98,7 +99,79 @@ radio_ubus_dummy_cb(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
return UBUS_STATUS_OK;
|
||||
}
|
||||
|
||||
enum {
|
||||
ADD_VIF_RADIO,
|
||||
ADD_VIF_NAME,
|
||||
ADD_VIF_VID,
|
||||
ADD_VIF_NETWORK,
|
||||
ADD_VIF_SSID,
|
||||
__ADD_VIF_MAX,
|
||||
};
|
||||
|
||||
static const struct blobmsg_policy add_vif_policy[__ADD_VIF_MAX] = {
|
||||
[ADD_VIF_RADIO] = { .name = "radio", .type = BLOBMSG_TYPE_STRING },
|
||||
[ADD_VIF_NAME] = { .name = "name", .type = BLOBMSG_TYPE_STRING },
|
||||
[ADD_VIF_VID] = { .name = "vid", .type = BLOBMSG_TYPE_INT32 },
|
||||
[ADD_VIF_NETWORK] = { .name = "network", .type = BLOBMSG_TYPE_STRING },
|
||||
[ADD_VIF_SSID] = { .name = "ssid", .type = BLOBMSG_TYPE_STRING },
|
||||
};
|
||||
|
||||
static int
|
||||
radio_ubus_add_vif_cb(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg)
|
||||
{
|
||||
struct blob_attr *tb[__ADD_VIF_MAX] = { };
|
||||
struct schema_Wifi_VIF_Config conf;
|
||||
char band[8];
|
||||
char *radio;
|
||||
|
||||
if (!msg)
|
||||
return UBUS_STATUS_INVALID_ARGUMENT;
|
||||
|
||||
blobmsg_parse(add_vif_policy, __ADD_VIF_MAX, tb, blob_data(msg), blob_len(msg));
|
||||
if (!tb[ADD_VIF_RADIO] || !tb[ADD_VIF_NAME] || !tb[ADD_VIF_VID] ||
|
||||
!tb[ADD_VIF_NETWORK] || !tb[ADD_VIF_SSID])
|
||||
return UBUS_STATUS_INVALID_ARGUMENT;
|
||||
|
||||
radio = blobmsg_get_string(tb[ADD_VIF_RADIO]);
|
||||
|
||||
memset(&conf, 0, sizeof(conf));
|
||||
schema_Wifi_VIF_Config_mark_all_present(&conf);
|
||||
conf._partial_update = true;
|
||||
conf._partial_update = true;
|
||||
|
||||
SCHEMA_SET_INT(conf.rrm, 1);
|
||||
SCHEMA_SET_INT(conf.ft_psk, 0);
|
||||
SCHEMA_SET_INT(conf.group_rekey, 0);
|
||||
strscpy(conf.mac_list_type, "none", sizeof(conf.mac_list_type));
|
||||
conf.mac_list_len = 0;
|
||||
SCHEMA_SET_STR(conf.if_name, blobmsg_get_string(tb[ADD_VIF_NAME]));
|
||||
SCHEMA_SET_STR(conf.ssid_broadcast, "enabled");
|
||||
SCHEMA_SET_STR(conf.mode, "ap");
|
||||
SCHEMA_SET_INT(conf.enabled, 1);
|
||||
SCHEMA_SET_INT(conf.btm, 1);
|
||||
SCHEMA_SET_INT(conf.uapsd_enable, true);
|
||||
SCHEMA_SET_STR(conf.bridge, blobmsg_get_string(tb[ADD_VIF_NETWORK]));
|
||||
SCHEMA_SET_INT(conf.vlan_id, blobmsg_get_u32(tb[ADD_VIF_VID]));
|
||||
SCHEMA_SET_STR(conf.ssid, blobmsg_get_string(tb[ADD_VIF_SSID]));
|
||||
STRSCPY(conf.security_keys[0], "encryption");
|
||||
STRSCPY(conf.security[0], "OPEN");
|
||||
conf.security_len = 1;
|
||||
|
||||
phy_get_band(target_map_ifname(radio), band);
|
||||
if (strstr(band, "5"))
|
||||
SCHEMA_SET_STR(conf.min_hw_mode, "11ac");
|
||||
else
|
||||
SCHEMA_SET_STR(conf.min_hw_mode, "11n");
|
||||
|
||||
radio_ops->op_vconf(&conf, radio);
|
||||
|
||||
return UBUS_STATUS_OK;
|
||||
}
|
||||
|
||||
static const struct ubus_method radio_ubus_methods[] = {
|
||||
UBUS_METHOD("dbg_add_vif", radio_ubus_add_vif_cb, add_vif_policy),
|
||||
UBUS_METHOD("dummy", radio_ubus_dummy_cb, dummy_policy),
|
||||
};
|
||||
|
||||
|
||||
@ -200,11 +200,13 @@ int uci_section_del(struct uci_context *uci, char *prefix, char *package, char *
|
||||
int uci_section_to_blob(struct uci_context *uci, char *package, char *section,
|
||||
struct blob_buf *buf, const struct uci_blob_param_list *param)
|
||||
{
|
||||
struct uci_package *p;
|
||||
struct uci_package *p = NULL;
|
||||
struct uci_section *s = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (uci_load(uci, package, &p))
|
||||
p = uci_lookup_package(uci, package);
|
||||
if (!p)
|
||||
return -1;
|
||||
s = uci_lookup_section(uci, p, section);
|
||||
if (!s)
|
||||
|
||||
@ -575,7 +575,7 @@ bool target_vif_config_set2(const struct schema_Wifi_VIF_Config *vconf,
|
||||
b.head, &wifi_iface_param, NULL);
|
||||
|
||||
if (vid)
|
||||
vlan_add((char *)vconf->if_name, vconf->vlan_id, vid);
|
||||
vlan_add((char *)vconf->if_name, vid, !strcmp(vconf->bridge, "wan"));
|
||||
else
|
||||
vlan_del((char *)vconf->if_name);
|
||||
|
||||
|
||||
@ -178,6 +178,7 @@ void vlan_add(char *vifname, int vid, int bridge)
|
||||
struct vlan *vlan = vlan_find(vid);
|
||||
struct vlan_vif *vif;
|
||||
|
||||
|
||||
if (!vlan) {
|
||||
vlan = malloc(sizeof(*vlan));
|
||||
if (!vlan) {
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include "ds.h"
|
||||
#include "target.h"
|
||||
|
||||
#include <linux/if.h>
|
||||
#include <libubox/blobmsg.h>
|
||||
#include "utils.h"
|
||||
|
||||
@ -36,6 +37,13 @@ static inline const char * __find_key(char *keyv, size_t keysz, char *datav, siz
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct iface_info {
|
||||
char name[IFNAMSIZ];
|
||||
int vid;
|
||||
};
|
||||
|
||||
extern int l3_device_split(char *l3_device, struct iface_info *info);
|
||||
|
||||
extern struct blob_buf b;
|
||||
extern ovsdb_table_t table_Wifi_Inet_Config;
|
||||
extern struct uci_context *uci;
|
||||
|
||||
@ -43,14 +43,14 @@ void dhcp_add(char *net, const char *lease_time, const char *start, const char *
|
||||
if (lease_time || start || limit) {
|
||||
blobmsg_add_string(&b, "start", start ? start : "10");
|
||||
blobmsg_add_string(&b, "limit", limit ? limit : "200");
|
||||
blobmsg_add_string(&b, "leastime", lease_time ? lease_time : "12h");
|
||||
blobmsg_add_string(&b, "leasetime", lease_time ? lease_time : "12h");
|
||||
blobmsg_add_string(&b, "dhcpv6", "server");
|
||||
blobmsg_add_string(&b, "ra", "server");
|
||||
blobmsg_add_u32(&b, "ignore", 0);
|
||||
} else {
|
||||
blobmsg_add_u32(&b, "ignore", 1);
|
||||
}
|
||||
blobmsg_add_bool(&b, "autogen", 1);
|
||||
blobmsg_add_u32(&b, "autogen", 1);
|
||||
|
||||
blob_to_uci_section(uci, "dhcp", net, "dhcp", b.head, &dhcp_param, NULL);
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
#include <syslog.h>
|
||||
#include "target.h"
|
||||
|
||||
#include "evsched.h"
|
||||
#include "netifd.h"
|
||||
#include "ubus.h"
|
||||
|
||||
@ -33,22 +34,8 @@ static int netifd_ubus_notify(struct ubus_context *ctx, struct ubus_object *obj,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void netifd_ubus_iface_dump(struct ubus_request *req,
|
||||
int type, struct blob_attr *msg)
|
||||
{
|
||||
wifi_inet_state_set(msg);
|
||||
wifi_inet_master_set(msg);
|
||||
}
|
||||
|
||||
static void netifd_ubus_subscribed(const char *path, uint32_t id, int add)
|
||||
{
|
||||
if (!strncmp(path, "network.", 8))
|
||||
ubus_invoke(ubus, id, "status", NULL, netifd_ubus_iface_dump, NULL, 1000);
|
||||
}
|
||||
|
||||
static struct ubus_instance ubus_instance = {
|
||||
.connect = netifd_ubus_connect,
|
||||
.subscribed = netifd_ubus_subscribed,
|
||||
.notify = netifd_ubus_notify,
|
||||
.list = {
|
||||
{
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
#include "netifd.h"
|
||||
#include "evsched.h"
|
||||
|
||||
#include <uci.h>
|
||||
#include <libubox/blobmsg.h>
|
||||
@ -48,6 +49,7 @@ const struct uci_blob_param_list network_param = {
|
||||
.params = network_policy,
|
||||
};
|
||||
|
||||
int reload_config = 0;
|
||||
ovsdb_table_t table_Wifi_Inet_Config;
|
||||
struct blob_buf b = { };
|
||||
struct blob_buf del = { };
|
||||
@ -57,6 +59,7 @@ static void wifi_inet_conf_load(struct uci_section *s)
|
||||
{
|
||||
struct blob_attr *tb[__NET_ATTR_MAX] = { };
|
||||
struct schema_Wifi_Inet_Config conf;
|
||||
struct iface_info info;
|
||||
char *ifname = NULL;
|
||||
|
||||
if (!strcmp(s->e.name, "loopback"))
|
||||
@ -114,6 +117,11 @@ static void wifi_inet_conf_load(struct uci_section *s)
|
||||
SCHEMA_SET_STR(conf.parent_ifname, &ifname[1]);
|
||||
else
|
||||
dhcp_get_config(&conf);
|
||||
if (ifname && !l3_device_split(ifname, &info)) {
|
||||
SCHEMA_SET_STR(conf.parent_ifname, info.name);
|
||||
if (info.vid)
|
||||
SCHEMA_SET_INT(conf.vlan_id, info.vid);
|
||||
}
|
||||
firewall_get_config(&conf);
|
||||
|
||||
if (!ovsdb_table_upsert(&table_Wifi_Inet_Config, &conf, false))
|
||||
@ -139,12 +147,19 @@ static int wifi_inet_conf_add(struct schema_Wifi_Inet_Config *iconf)
|
||||
else
|
||||
blobmsg_add_bool(&del, "disabled", 1);
|
||||
|
||||
if (strcmp(iconf->if_type, "eth")) {
|
||||
if (!iconf->parent_ifname_exists && strcmp(iconf->if_type, "eth")) {
|
||||
blobmsg_add_string(&b, "type", iconf->if_type);
|
||||
blobmsg_add_bool(&b, "vlan_filtering", 1);
|
||||
} else
|
||||
blobmsg_add_bool(&del, "type", 1);
|
||||
|
||||
if (iconf->parent_ifname_exists && iconf->vlan_id > 2 && !strcmp(iconf->if_type, "eth")) {
|
||||
char uci_ifname[256];
|
||||
|
||||
snprintf(uci_ifname, sizeof(uci_ifname), "br-%s.%d", iconf->parent_ifname, iconf->vlan_id);
|
||||
blobmsg_add_string(&b, "ifname", uci_ifname);
|
||||
}
|
||||
|
||||
if (iconf->ip_assign_scheme_exists) {
|
||||
if (is_ipv6 && !strcmp(iconf->ip_assign_scheme, "dhcp"))
|
||||
blobmsg_add_string(&b, "proto", "dhcpv6");
|
||||
@ -178,6 +193,7 @@ static int wifi_inet_conf_add(struct schema_Wifi_Inet_Config *iconf)
|
||||
}
|
||||
|
||||
uci_commit_all(uci);
|
||||
reload_config = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -186,7 +202,7 @@ static void wifi_inet_conf_del(struct schema_Wifi_Inet_Config *iconf)
|
||||
{
|
||||
if (!strcmp(iconf->if_name, "wan") || !strcmp(iconf->if_name, "lan")) {
|
||||
blob_buf_init(&b, 0);
|
||||
blobmsg_add_bool(&b, "disabled", 1);
|
||||
blobmsg_add_string(&b, "proto", "none");
|
||||
blob_to_uci_section(uci, "network", iconf->if_name, "interface", b.head, &network_param, NULL);
|
||||
return;
|
||||
}
|
||||
@ -196,6 +212,7 @@ static void wifi_inet_conf_del(struct schema_Wifi_Inet_Config *iconf)
|
||||
|
||||
uci_section_del(uci, "network", "network", iconf->if_name, "interface");
|
||||
uci_commit_all(uci);
|
||||
reload_config = 1;
|
||||
}
|
||||
|
||||
static void callback_Wifi_Inet_Config(ovsdb_update_monitor_t *mon,
|
||||
@ -217,6 +234,17 @@ static void callback_Wifi_Inet_Config(ovsdb_update_monitor_t *mon,
|
||||
return;
|
||||
}
|
||||
|
||||
static void periodic_task(void *arg)
|
||||
{
|
||||
if (reload_config) {
|
||||
uci_commit_all(uci);
|
||||
system("reload_config");
|
||||
reload_config = 0;
|
||||
}
|
||||
|
||||
evsched_task_reschedule_ms(EVSCHED_SEC(5));
|
||||
}
|
||||
|
||||
void wifi_inet_config_init(void)
|
||||
{
|
||||
struct uci_element *e = NULL;
|
||||
@ -236,6 +264,7 @@ void wifi_inet_config_init(void)
|
||||
}
|
||||
|
||||
OVSDB_TABLE_MONITOR(Wifi_Inet_Config, false);
|
||||
evsched_task(&periodic_task, NULL, EVSCHED_SEC(5));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -65,6 +65,24 @@ static const struct blobmsg_policy route_policy[__ROUTE_ATTR_MAX] = {
|
||||
static ovsdb_table_t table_Wifi_Inet_State;
|
||||
static ovsdb_table_t table_Wifi_Master_State;
|
||||
|
||||
int l3_device_split(char *l3_device, struct iface_info *info)
|
||||
{
|
||||
char *dot;
|
||||
|
||||
if (strncmp(l3_device, "br-", 3))
|
||||
return -1;
|
||||
memset (info, 0, sizeof(*info));
|
||||
dot = strstr(l3_device, ".");
|
||||
if (!dot) {
|
||||
strcpy(info->name, &l3_device[3]);
|
||||
} else {
|
||||
strncpy(info->name, &l3_device[3], dot - l3_device - 3);
|
||||
info->vid = atoi(&dot[1]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wifi_inet_state_set(struct blob_attr *msg)
|
||||
{
|
||||
struct blob_attr *tb[__NET_ATTR_MAX] = { };
|
||||
@ -96,6 +114,7 @@ void wifi_inet_state_set(struct blob_attr *msg)
|
||||
if (tb[NET_ATTR_L3_DEVICE]) {
|
||||
char *l3_device = blobmsg_get_string(tb[NET_ATTR_L3_DEVICE]);
|
||||
char mac[ETH_ALEN * 3];
|
||||
struct iface_info info;
|
||||
|
||||
mtu = net_get_mtu(l3_device);
|
||||
if (mtu > 0)
|
||||
@ -106,6 +125,11 @@ void wifi_inet_state_set(struct blob_attr *msg)
|
||||
SCHEMA_SET_STR(state.if_type, "bridge");
|
||||
else
|
||||
SCHEMA_SET_STR(state.if_type, "eth");
|
||||
if (!l3_device_split(l3_device, &info) && strcmp(info.name, state.if_name)) {
|
||||
SCHEMA_SET_STR(state.parent_ifname, info.name);
|
||||
if (info.vid)
|
||||
SCHEMA_SET_INT(state.vlan_id, info.vid);
|
||||
}
|
||||
} else
|
||||
SCHEMA_SET_STR(state.if_type, "eth");
|
||||
|
||||
|
||||
@ -1,37 +1,6 @@
|
||||
# Copyright (c) 2015, Plume Design Inc. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the Plume Design Inc. nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL Plume Design Inc. BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Network manager
|
||||
#
|
||||
###############################################################################
|
||||
UNIT_DISABLE := $(if $(CONFIG_MANAGER_NM),n,y)
|
||||
|
||||
UNIT_NAME := nm
|
||||
|
||||
# Template type:
|
||||
UNIT_TYPE := BIN
|
||||
|
||||
UNIT_SRC += src/ubus.c
|
||||
@ -47,9 +16,6 @@ UNIT_CFLAGS += -Isrc/lib/version/inc/
|
||||
|
||||
UNIT_LDFLAGS += -lev -lubus -lubox -luci -lblobmsg_json -lnl-tiny
|
||||
UNIT_LDFLAGS += -lrt
|
||||
#ifneq ($(BUILD_SHARED_LIB),y)
|
||||
#UNIT_LDFLAGS += -lpcap
|
||||
#endif
|
||||
|
||||
UNIT_EXPORT_CFLAGS := $(UNIT_CFLAGS)
|
||||
UNIT_EXPORT_LDFLAGS := $(UNIT_LDFLAGS)
|
||||
|
||||
@ -1,34 +0,0 @@
|
||||
From 7abb5379916e94316158ba508f56cc6248dbf933 Mon Sep 17 00:00:00 2001
|
||||
From: John Crispin <john@phrozen.org>
|
||||
Date: Wed, 29 Jul 2020 12:30:42 +0200
|
||||
Subject: [PATCH] netifd: add interface to status messages
|
||||
|
||||
Add the interface name to the status messages. Otherwise we cannot identify the content.
|
||||
|
||||
Signed-off-by: John Crispin <john@phrozen.org>
|
||||
---
|
||||
.../config/netifd/patches/0103-ubus-iface.patch | 12 ++++++++++++
|
||||
1 file changed, 12 insertions(+)
|
||||
create mode 100644 package/network/config/netifd/patches/0103-ubus-iface.patch
|
||||
|
||||
diff --git a/package/network/config/netifd/patches/0103-ubus-iface.patch b/package/network/config/netifd/patches/0103-ubus-iface.patch
|
||||
new file mode 100644
|
||||
index 0000000000..f11477217a
|
||||
--- /dev/null
|
||||
+++ b/package/network/config/netifd/patches/0103-ubus-iface.patch
|
||||
@@ -0,0 +1,12 @@
|
||||
+Index: netifd-2019-08-05-5e02f944/ubus.c
|
||||
+===================================================================
|
||||
+--- netifd-2019-08-05-5e02f944.orig/ubus.c
|
||||
++++ netifd-2019-08-05-5e02f944/ubus.c
|
||||
+@@ -825,6 +825,7 @@ netifd_handle_status(struct ubus_context
|
||||
+ struct interface *iface = container_of(obj, struct interface, ubus);
|
||||
+
|
||||
+ blob_buf_init(&b, 0);
|
||||
++ blobmsg_add_string(&b, "interface", iface->name);
|
||||
+ netifd_dump_status(iface);
|
||||
+ ubus_send_reply(ctx, req, b.head);
|
||||
+
|
||||
--
|
||||
2.25.1
|
||||
|
||||
55
patches/backports/0004-netifd-send-status-on-subscribe.patch
Normal file
55
patches/backports/0004-netifd-send-status-on-subscribe.patch
Normal file
@ -0,0 +1,55 @@
|
||||
From a504e3759a3198a1fb499cef8acb01ebd839ee22 Mon Sep 17 00:00:00 2001
|
||||
From: John Crispin <john@phrozen.org>
|
||||
Date: Wed, 29 Jul 2020 12:30:42 +0200
|
||||
Subject: [PATCH 01/27] netifd: add interface to status messages
|
||||
|
||||
Add the interface name to the status messages. Otherwise we cannot identify the content.
|
||||
|
||||
Signed-off-by: John Crispin <john@phrozen.org>
|
||||
---
|
||||
.../netifd/patches/0103-ubus-iface.patch | 33 +++++++++++++++++++
|
||||
1 file changed, 33 insertions(+)
|
||||
create mode 100644 package/network/config/netifd/patches/0103-ubus-iface.patch
|
||||
|
||||
diff --git a/package/network/config/netifd/patches/0103-ubus-iface.patch b/package/network/config/netifd/patches/0103-ubus-iface.patch
|
||||
new file mode 100644
|
||||
index 0000000000..2c489fe96a
|
||||
--- /dev/null
|
||||
+++ b/package/network/config/netifd/patches/0103-ubus-iface.patch
|
||||
@@ -0,0 +1,33 @@
|
||||
+Index: netifd-2019-08-05-5e02f944/ubus.c
|
||||
+===================================================================
|
||||
+--- netifd-2019-08-05-5e02f944.orig/ubus.c
|
||||
++++ netifd-2019-08-05-5e02f944/ubus.c
|
||||
+@@ -1276,6 +1276,20 @@ netifd_ubus_interface_notify(struct inte
|
||||
+ ubus_notify(ubus_ctx, &iface->ubus, event, b.head, -1);
|
||||
+ }
|
||||
+
|
||||
++static void
|
||||
++iface_subscribe_handler(struct ubus_context *ctx, struct ubus_object *obj)
|
||||
++{
|
||||
++ struct interface *iface;
|
||||
++
|
||||
++ iface = container_of(obj, struct interface, ubus);
|
||||
++ if (!iface->ubus.has_subscribers)
|
||||
++ return;
|
||||
++ blob_buf_init(&b, 0);
|
||||
++ blobmsg_add_string(&b, "interface", iface->name);
|
||||
++ netifd_dump_status(iface);
|
||||
++ ubus_notify(ubus_ctx, &iface->ubus, "interface.update", b.head, -1);
|
||||
++}
|
||||
++
|
||||
+ void
|
||||
+ netifd_ubus_add_interface(struct interface *iface)
|
||||
+ {
|
||||
+@@ -1289,6 +1303,7 @@ netifd_ubus_add_interface(struct interfa
|
||||
+ obj->type = &iface_object_type;
|
||||
+ obj->methods = iface_object_methods;
|
||||
+ obj->n_methods = ARRAY_SIZE(iface_object_methods);
|
||||
++ obj->subscribe_cb = iface_subscribe_handler;
|
||||
+ if (ubus_add_object(ubus_ctx, &iface->ubus)) {
|
||||
+ DPRINTF("failed to publish ubus object for interface '%s'\n", iface->name);
|
||||
+ free(name);
|
||||
--
|
||||
2.25.1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user