[01/12] images: add a network namespace id into images

Submitted by Andrei Vagin on Feb. 28, 2017, 11:52 p.m.

Details

Message ID 1488325988-28456-2-git-send-email-avagin@openvz.org
State New
Series "Dump and restore internal veth devices"
Headers show

Commit Message

Andrei Vagin Feb. 28, 2017, 11:52 p.m.
From: Andrei Vagin <avagin@virtuozzo.com>

It is possible to assign id for network namespaces and
this id will be used by the kernel in some netlink messages.
If no id is assigned when the kernel needs it, it will be
automatically assigned by the kernel.

For example, this id is reported for peer veth devices.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
---
 images/netdev.proto | 10 ++++++++++
 1 file changed, 10 insertions(+)

Patch hide | download patch | download mbox

diff --git a/images/netdev.proto b/images/netdev.proto
index 2f2f3d1..5bf39ef 100644
--- a/images/netdev.proto
+++ b/images/netdev.proto
@@ -42,6 +42,14 @@  message net_device_entry {
 	repeated sysctl_entry conf6	= 10;
 
 	optional macvlan_link_entry	macvlan		= 11;
+
+	optional uint32 peer_ifindex	= 12;
+	optional uint32 peer_nsid	= 13;
+}
+
+message netns_id {
+	required uint32	id	= 1;
+	required int32	nsid	= 2;
 }
 
 message netns_entry {
@@ -53,4 +61,6 @@  message netns_entry {
 
 	repeated sysctl_entry def_conf6	= 5;
 	repeated sysctl_entry all_conf6	= 6;
+
+	repeated netns_id nsids		= 7;
 }

Comments

Pavel Emelianov March 13, 2017, 10:44 a.m.
On 03/01/2017 02:52 AM, Andrei Vagin wrote:
> From: Andrei Vagin <avagin@virtuozzo.com>
> 
> It is possible to assign id for network namespaces and
> this id will be used by the kernel in some netlink messages.
> If no id is assigned when the kernel needs it, it will be
> automatically assigned by the kernel.
> 
> For example, this id is reported for peer veth devices.
> 
> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
> ---
>  images/netdev.proto | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/images/netdev.proto b/images/netdev.proto
> index 2f2f3d1..5bf39ef 100644
> --- a/images/netdev.proto
> +++ b/images/netdev.proto
> @@ -42,6 +42,14 @@ message net_device_entry {
>  	repeated sysctl_entry conf6	= 10;
>  
>  	optional macvlan_link_entry	macvlan		= 11;
> +
> +	optional uint32 peer_ifindex	= 12;
> +	optional uint32 peer_nsid	= 13;
> +}
> +
> +message netns_id {
> +	required uint32	id	= 1;
> +	required int32	nsid	= 2;

Would you explain why netns_id has two integers and why one of
them can be negative?

>  }
>  
>  message netns_entry {
> @@ -53,4 +61,6 @@ message netns_entry {
>  
>  	repeated sysctl_entry def_conf6	= 5;
>  	repeated sysctl_entry all_conf6	= 6;
> +
> +	repeated netns_id nsids		= 7;
>  }
>
Andrey Vagin March 17, 2017, 6:19 p.m.
On Mon, Mar 13, 2017 at 01:44:03PM +0300, Pavel Emelyanov wrote:
> On 03/01/2017 02:52 AM, Andrei Vagin wrote:
> > From: Andrei Vagin <avagin@virtuozzo.com>
> > 
> > It is possible to assign id for network namespaces and
> > this id will be used by the kernel in some netlink messages.
> > If no id is assigned when the kernel needs it, it will be
> > automatically assigned by the kernel.
> > 
> > For example, this id is reported for peer veth devices.
> > 
> > Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
> > ---
> >  images/netdev.proto | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/images/netdev.proto b/images/netdev.proto
> > index 2f2f3d1..5bf39ef 100644
> > --- a/images/netdev.proto
> > +++ b/images/netdev.proto
> > @@ -42,6 +42,14 @@ message net_device_entry {
> >  	repeated sysctl_entry conf6	= 10;
> >  
> >  	optional macvlan_link_entry	macvlan		= 11;
> > +
> > +	optional uint32 peer_ifindex	= 12;
> > +	optional uint32 peer_nsid	= 13;
> > +}
> > +
> > +message netns_id {
> > +	required uint32	id	= 1;
> > +	required int32	nsid	= 2;
> 
> Would you explain why netns_id has two integers and why one of
> them can be negative?

I will add a comment. Here id is ns->id. Each net namespace has own set
of of nsid-s for other namespaces.

> 
> >  }
> >  
> >  message netns_entry {
> > @@ -53,4 +61,6 @@ message netns_entry {
> >  
> >  	repeated sysctl_entry def_conf6	= 5;
> >  	repeated sysctl_entry all_conf6	= 6;
> > +
> > +	repeated netns_id nsids		= 7;
> >  }
> > 
>
Pavel Emelianov March 21, 2017, 10:30 a.m.
On 03/17/2017 09:19 PM, Andrei Vagin wrote:
> On Mon, Mar 13, 2017 at 01:44:03PM +0300, Pavel Emelyanov wrote:
>> On 03/01/2017 02:52 AM, Andrei Vagin wrote:
>>> From: Andrei Vagin <avagin@virtuozzo.com>
>>>
>>> It is possible to assign id for network namespaces and
>>> this id will be used by the kernel in some netlink messages.
>>> If no id is assigned when the kernel needs it, it will be
>>> automatically assigned by the kernel.
>>>
>>> For example, this id is reported for peer veth devices.
>>>
>>> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
>>> ---
>>>  images/netdev.proto | 10 ++++++++++
>>>  1 file changed, 10 insertions(+)
>>>
>>> diff --git a/images/netdev.proto b/images/netdev.proto
>>> index 2f2f3d1..5bf39ef 100644
>>> --- a/images/netdev.proto
>>> +++ b/images/netdev.proto
>>> @@ -42,6 +42,14 @@ message net_device_entry {
>>>  	repeated sysctl_entry conf6	= 10;
>>>  
>>>  	optional macvlan_link_entry	macvlan		= 11;
>>> +
>>> +	optional uint32 peer_ifindex	= 12;
>>> +	optional uint32 peer_nsid	= 13;
>>> +}
>>> +
>>> +message netns_id {
>>> +	required uint32	id	= 1;
>>> +	required int32	nsid	= 2;
>>
>> Would you explain why netns_id has two integers and why one of
>> them can be negative?
> 
> I will add a comment. Here id is ns->id. Each net namespace has own set
> of of nsid-s for other namespaces.

OK, so one field is effectively target ns id and references
netns_entry object, while the other one is the user-defined
value.

I propose to name them target_ns_id and nsid_value and ...
still explain why the latter one can be negative :)

>>
>>>  }
>>>  
>>>  message netns_entry {
>>> @@ -53,4 +61,6 @@ message netns_entry {
>>>  
>>>  	repeated sysctl_entry def_conf6	= 5;
>>>  	repeated sysctl_entry all_conf6	= 6;
>>> +
>>> +	repeated netns_id nsids		= 7;
>>>  }
>>>
>>
> .
>