[OpenWrt-Devel,1/2] Introduce new interface event "create" (IFEV_CREATE)
diff mbox series

Message ID 20180629032315.7906-1-lynxis@fe80.eu
State Accepted
Headers show
Series
  • [OpenWrt-Devel,1/2] Introduce new interface event "create" (IFEV_CREATE)
Related show

Commit Message

Alexander Couzens June 29, 2018, 3:23 a.m. UTC
"create" will be called before the proto handlers initialised.
---
 interface-event.c | 1 +
 interface.c       | 1 +
 interface.h       | 2 ++
 3 files changed, 4 insertions(+)

Comments

Alexander Couzens June 29, 2018, 3:32 a.m. UTC | #1
Hi Hans,

pls don't commit them. 
I've forgot the SOB line, but also would like to add a GPG signature to
it, after you've reviewed them.

Best,
lynxis
Hans Dedecker June 29, 2018, 2:14 p.m. UTC | #2
On Fri, Jun 29, 2018 at 5:23 AM Alexander Couzens <lynxis@fe80.eu> wrote:
>
> "create" will be called before the proto handlers initialised.
Acked-by: Hans Dedecker <dedeckeh@gmail.com>
> ---
>  interface-event.c | 1 +
>  interface.c       | 1 +
>  interface.h       | 2 ++
>  3 files changed, 4 insertions(+)
>
> diff --git a/interface-event.c b/interface-event.c
> index 86e8f5488da8..a40f6dc883d3 100644
> --- a/interface-event.c
> +++ b/interface-event.c
> @@ -38,6 +38,7 @@ static const char * const eventnames[] = {
>         [IFEV_FREE] = "free",
>         [IFEV_RELOAD] = "reload",
>         [IFEV_LINK_UP] = "iflink",
> +       [IFEV_CREATE] = "create",
>  };
>
>  static void
> diff --git a/interface.c b/interface.c
> index 2a23984922a1..400c605efc0c 100644
> --- a/interface.c
> +++ b/interface.c
> @@ -1275,6 +1275,7 @@ interface_update(struct vlist_tree *tree, struct vlist_node *node_new,
>                 set_config_state(if_old, IFC_REMOVE);
>         } else if (node_new) {
>                 D(INTERFACE, "Create interface '%s'\n", if_new->name);
> +               interface_event(if_new, IFEV_CREATE);
>                 proto_init_interface(if_new, if_new->config);
>                 interface_claim_device(if_new);
>                 netifd_ubus_add_interface(if_new);
> diff --git a/interface.h b/interface.h
> index 0e58f69c26e0..e5639eb326cd 100644
> --- a/interface.h
> +++ b/interface.h
> @@ -28,6 +28,8 @@ enum interface_event {
>         IFEV_FREE,
>         IFEV_RELOAD,
>         IFEV_LINK_UP,
> +       /* send when a new interface created. This is before proto handlers has been attached. */
> +       IFEV_CREATE,
>  };
>
>  enum interface_state {
> --
> 2.18.0
>
Paul Oranje July 3, 2018, 5:26 p.m. UTC | #3
Curious: what purposes or use-cases are intended to be served with this event ?


> Op 29 jun. 2018, om 16:14 heeft Hans Dedecker <dedeckeh@gmail.com> het volgende geschreven:
> 
> On Fri, Jun 29, 2018 at 5:23 AM Alexander Couzens <lynxis@fe80.eu> wrote:
>> 
>> "create" will be called before the proto handlers initialised.
> Acked-by: Hans Dedecker <dedeckeh@gmail.com>
>> ---
>> interface-event.c | 1 +
>> interface.c       | 1 +
>> interface.h       | 2 ++
>> 3 files changed, 4 insertions(+)
>> 
>> diff --git a/interface-event.c b/interface-event.c
>> index 86e8f5488da8..a40f6dc883d3 100644
>> --- a/interface-event.c
>> +++ b/interface-event.c
>> @@ -38,6 +38,7 @@ static const char * const eventnames[] = {
>>        [IFEV_FREE] = "free",
>>        [IFEV_RELOAD] = "reload",
>>        [IFEV_LINK_UP] = "iflink",
>> +       [IFEV_CREATE] = "create",
>> };
>> 
>> static void
>> diff --git a/interface.c b/interface.c
>> index 2a23984922a1..400c605efc0c 100644
>> --- a/interface.c
>> +++ b/interface.c
>> @@ -1275,6 +1275,7 @@ interface_update(struct vlist_tree *tree, struct vlist_node *node_new,
>>                set_config_state(if_old, IFC_REMOVE);
>>        } else if (node_new) {
>>                D(INTERFACE, "Create interface '%s'\n", if_new->name);
>> +               interface_event(if_new, IFEV_CREATE);
>>                proto_init_interface(if_new, if_new->config);
>>                interface_claim_device(if_new);
>>                netifd_ubus_add_interface(if_new);
>> diff --git a/interface.h b/interface.h
>> index 0e58f69c26e0..e5639eb326cd 100644
>> --- a/interface.h
>> +++ b/interface.h
>> @@ -28,6 +28,8 @@ enum interface_event {
>>        IFEV_FREE,
>>        IFEV_RELOAD,
>>        IFEV_LINK_UP,
>> +       /* send when a new interface created. This is before proto handlers has been attached. */
>> +       IFEV_CREATE,
>> };
>> 
>> enum interface_state {
>> --
>> 2.18.0
>> 
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Hans Dedecker July 3, 2018, 8:46 p.m. UTC | #4
On Tue, Jul 3, 2018 at 7:26 PM Paul Oranje <por@oranjevos.nl> wrote:
>
> Curious: what purposes or use-cases are intended to be served with this event ?
Please don't top post

The interface event IFEV_CREATE can be used by external applications
or netifd internal subsystems to trigger specific logic when an
interface is created; patch http://patchwork.ozlabs.org/patch/937167/
makes use of this event

Hans
>
>
> > Op 29 jun. 2018, om 16:14 heeft Hans Dedecker <dedeckeh@gmail.com> het volgende geschreven:
> >
> > On Fri, Jun 29, 2018 at 5:23 AM Alexander Couzens <lynxis@fe80.eu> wrote:
> >>
> >> "create" will be called before the proto handlers initialised.
> > Acked-by: Hans Dedecker <dedeckeh@gmail.com>
> >> ---
> >> interface-event.c | 1 +
> >> interface.c       | 1 +
> >> interface.h       | 2 ++
> >> 3 files changed, 4 insertions(+)
> >> diff --git a/interface-event.c b/interface-event.c
> >> index 86e8f5488da8..a40f6dc883d3 100644
> >> --- a/interface-event.c
> >> +++ b/interface-event.c
> >> @@ -38,6 +38,7 @@ static const char * const eventnames[] = {
> >>        [IFEV_FREE] = "free",
> >>        [IFEV_RELOAD] = "reload",
> >>        [IFEV_LINK_UP] = "iflink",
> >> +       [IFEV_CREATE] = "create",
> >> };
> >>
> >> static void
> >> diff --git a/interface.c b/interface.c
> >> index 2a23984922a1..400c605efc0c 100644
> >> --- a/interface.c
> >> +++ b/interface.c
> >> @@ -1275,6 +1275,7 @@ interface_update(struct vlist_tree *tree, struct vlist_node *node_new,
> >>                set_config_state(if_old, IFC_REMOVE);
> >>        } else if (node_new) {
> >>                D(INTERFACE, "Create interface '%s'\n", if_new->name);
> >> +               interface_event(if_new, IFEV_CREATE);
> >>                proto_init_interface(if_new, if_new->config);
> >>                interface_claim_device(if_new);
> >>                netifd_ubus_add_interface(if_new);
> >> diff --git a/interface.h b/interface.h
> >> index 0e58f69c26e0..e5639eb326cd 100644
> >> --- a/interface.h
> >> +++ b/interface.h
> >> @@ -28,6 +28,8 @@ enum interface_event {
> >>        IFEV_FREE,
> >>        IFEV_RELOAD,
> >>        IFEV_LINK_UP,
> >> +       /* send when a new interface created. This is before proto handlers has been attached. */
> >> +       IFEV_CREATE,
> >> };
> >>
> >> enum interface_state {
> >> --
> >> 2.18.0
> >>
> >
> > _______________________________________________
> > openwrt-devel mailing list
> > openwrt-devel@lists.openwrt.org
> > https://lists.openwrt.org/mailman/listinfo/openwrt-devel
>

Patch
diff mbox series

diff --git a/interface-event.c b/interface-event.c
index 86e8f5488da8..a40f6dc883d3 100644
--- a/interface-event.c
+++ b/interface-event.c
@@ -38,6 +38,7 @@  static const char * const eventnames[] = {
 	[IFEV_FREE] = "free",
 	[IFEV_RELOAD] = "reload",
 	[IFEV_LINK_UP] = "iflink",
+	[IFEV_CREATE] = "create",
 };
 
 static void
diff --git a/interface.c b/interface.c
index 2a23984922a1..400c605efc0c 100644
--- a/interface.c
+++ b/interface.c
@@ -1275,6 +1275,7 @@  interface_update(struct vlist_tree *tree, struct vlist_node *node_new,
 		set_config_state(if_old, IFC_REMOVE);
 	} else if (node_new) {
 		D(INTERFACE, "Create interface '%s'\n", if_new->name);
+		interface_event(if_new, IFEV_CREATE);
 		proto_init_interface(if_new, if_new->config);
 		interface_claim_device(if_new);
 		netifd_ubus_add_interface(if_new);
diff --git a/interface.h b/interface.h
index 0e58f69c26e0..e5639eb326cd 100644
--- a/interface.h
+++ b/interface.h
@@ -28,6 +28,8 @@  enum interface_event {
 	IFEV_FREE,
 	IFEV_RELOAD,
 	IFEV_LINK_UP,
+	/* send when a new interface created. This is before proto handlers has been attached. */
+	IFEV_CREATE,
 };
 
 enum interface_state {