Skip to content
Snippets Groups Projects
Verified Commit 171cf63d authored by Vivek Dutta's avatar Vivek Dutta
Browse files

Removed hotplug.ethernet call on network.device event

parent 9c245d2c
Branches
No related tags found
1 merge request!31Removed hotplug.ethernet call on network.device event
Pipeline #201063 failed
...@@ -25,59 +25,6 @@ ...@@ -25,59 +25,6 @@
struct bbfdm_context bbfdm_ctx = {0}; struct bbfdm_context bbfdm_ctx = {0};
static void eth_port_handler_cb(struct ubus_context *ctx,
struct ubus_event_handler *ev __attribute__((unused)),
const char *type, struct blob_attr *msg)
{
if (DM_STRCMP(type, "network.device") != 0)
return;
enum {
NET_DEV_POLICY_IFNAME,
NET_DEV_POLICY_LINK,
_MAX_NET_DEV_POLICY
};
struct blobmsg_policy net_dev_policy[_MAX_NET_DEV_POLICY] = {
[NET_DEV_POLICY_IFNAME] = { .name = "ifname", .type = BLOBMSG_TYPE_STRING },
[NET_DEV_POLICY_LINK] = { .name = "link", .type = BLOBMSG_TYPE_STRING },
};
struct blob_attr *tb[_MAX_NET_DEV_POLICY];
char ifname[32] = {0};
char link[32] = {0};
blobmsg_parse(net_dev_policy, _MAX_NET_DEV_POLICY, tb, blobmsg_data(msg), blobmsg_len(msg));
if (!tb[NET_DEV_POLICY_IFNAME]) {
BBF_ERR("\"ifname\" not found in network.device event!");
return;
}
if (!tb[NET_DEV_POLICY_LINK]) {
BBF_ERR("\"link\" not found in network.device event!");
return;
}
snprintf(ifname, sizeof(ifname), "%s", blobmsg_get_string(tb[NET_DEV_POLICY_IFNAME]));
snprintf(link, sizeof(link), "%s", blobmsg_get_string(tb[NET_DEV_POLICY_LINK]));
invoke_ethernet_hotplug(ctx, ifname, link);
}
static int register_ethernet_event(struct ubus_context *ctx)
{
int ret;
struct ubus_event_handler ev = {0};
memset(&ev, 0, sizeof(struct ubus_event_handler));
ev.cb = eth_port_handler_cb;
ret = ubus_register_event_handler(ctx, &ev, "network.device");
return ret;
}
#ifdef ETHMNGR_EXPOSE_ETHERNET_OBJECT #ifdef ETHMNGR_EXPOSE_ETHERNET_OBJECT
/* ifstats policy */ /* ifstats policy */
enum { enum {
...@@ -344,9 +291,6 @@ int main(int argc, char **argv) ...@@ -344,9 +291,6 @@ int main(int argc, char **argv)
goto out; goto out;
#endif #endif
if (register_ethernet_event(&bbfdm_ctx.ubus_ctx) != 0)
goto out;
uloop_run(); uloop_run();
out: out:
bbfdm_ubus_regiter_free(&bbfdm_ctx); bbfdm_ubus_regiter_free(&bbfdm_ctx);
......
...@@ -15,47 +15,6 @@ ...@@ -15,47 +15,6 @@
#include "helper.h" #include "helper.h"
static void ubus_call(struct ubus_context *ctx, const char *obj, const char *method,
struct blob_attr *msg, ubus_data_handler_t cb, void *value)
{
uint32_t id;
if (ctx == NULL || obj == NULL)
return;
if (!ubus_lookup_id(ctx, obj, &id)) {
ubus_invoke(ctx, id, method, msg, cb, value, 5000);
}
}
void invoke_ethernet_hotplug(struct ubus_context *ctx, char *ifname, char *link)
{
if (ctx == NULL || ifname == NULL || link == NULL)
return;
if (strlen(ifname) == 0 || strlen(link) == 0)
return;
char env_port[56] = {0};
char env_link[56] = {0};
struct blob_buf b = {0};
snprintf(env_port, sizeof(env_port), "PORT=%s", ifname);
snprintf(env_link, sizeof(env_link), "LINK=%s", link);
memset(&b, 0, sizeof(struct blob_buf));
blob_buf_init(&b, 0);
void *arr = blobmsg_open_array(&b, "env");
blobmsg_add_string(&b, NULL, env_port);
blobmsg_add_string(&b, NULL, env_link);
blobmsg_close_array(&b, arr);
ubus_call(ctx, "hotplug.ethernet", "call", b.head, NULL, NULL);
blob_buf_free(&b);
}
int ethmngr_clear_stats(char *ifname) int ethmngr_clear_stats(char *ifname)
{ {
if (ifname == NULL) if (ifname == NULL)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment