diff mbox series

[netifd,3/4] device_addr: record address index as in the blob

Message ID 20201021030825.93626-4-yszhou4tech@gmail.com
State Accepted
Delegated to: Yousong Zhou
Headers show
Series order by address index in ubus output | expand

Commit Message

Yousong Zhou Oct. 21, 2020, 3:08 a.m. UTC
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
---
 interface-ip.h | 1 +
 proto.c        | 2 ++
 2 files changed, 3 insertions(+)

Comments

Hans Dedecker Oct. 21, 2020, 7:10 p.m. UTC | #1
On Wed, Oct 21, 2020 at 5:08 AM Yousong Zhou <yszhou4tech@gmail.com> wrote:
>
> Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Acked-by: Hans Dedecker <dedeckeh@gmail>
> ---
>  interface-ip.h | 1 +
>  proto.c        | 2 ++
>  2 files changed, 3 insertions(+)
>
> diff --git a/interface-ip.h b/interface-ip.h
> index 5ab9299..b17ad94 100644
> --- a/interface-ip.h
> +++ b/interface-ip.h
> @@ -127,6 +127,7 @@ struct device_addr {
>         struct vlist_node node;
>         bool enabled;
>         bool failed;
> +       int index;
>         unsigned int policy_table;
>
>         struct device_route subnet;
> diff --git a/proto.c b/proto.c
> index d80cae0..f7d27aa 100644
> --- a/proto.c
> +++ b/proto.c
> @@ -172,6 +172,7 @@ parse_static_address_option(struct interface *iface, struct blob_attr *attr,
>                         interface_add_error(iface, "proto", "INVALID_ADDRESS", &str, 1);
>                         return -1;
>                 }
> +               addr->index = n_addr;
>                 n_addr++;
>                 vlist_add(&iface->proto_ip.addr, &addr->node, &addr->flags);
>         }
> @@ -272,6 +273,7 @@ parse_address_list(struct interface *iface, struct blob_attr *attr, bool v6,
>                 if (!addr)
>                         return -1;
>
> +               addr->index = n_addr;
>                 n_addr++;
>                 vlist_add(&iface->proto_ip.addr, &addr->node, &addr->flags);
>         }
diff mbox series

Patch

diff --git a/interface-ip.h b/interface-ip.h
index 5ab9299..b17ad94 100644
--- a/interface-ip.h
+++ b/interface-ip.h
@@ -127,6 +127,7 @@  struct device_addr {
 	struct vlist_node node;
 	bool enabled;
 	bool failed;
+	int index;
 	unsigned int policy_table;
 
 	struct device_route subnet;
diff --git a/proto.c b/proto.c
index d80cae0..f7d27aa 100644
--- a/proto.c
+++ b/proto.c
@@ -172,6 +172,7 @@  parse_static_address_option(struct interface *iface, struct blob_attr *attr,
 			interface_add_error(iface, "proto", "INVALID_ADDRESS", &str, 1);
 			return -1;
 		}
+		addr->index = n_addr;
 		n_addr++;
 		vlist_add(&iface->proto_ip.addr, &addr->node, &addr->flags);
 	}
@@ -272,6 +273,7 @@  parse_address_list(struct interface *iface, struct blob_attr *attr, bool v6,
 		if (!addr)
 			return -1;
 
+		addr->index = n_addr;
 		n_addr++;
 		vlist_add(&iface->proto_ip.addr, &addr->node, &addr->flags);
 	}