[CRIU] [PATCH 11/12] net: dump and restore connected to a bridge links

Andrei Vagin avagin at virtuozzo.com
Mon Mar 20 14:15:30 PDT 2017


On Mon, Mar 13, 2017 at 01:58:02PM +0300, Pavel Emelyanov wrote:
> 
> > @@ -1369,37 +1344,110 @@ exit:
> >  	return ret;
> >  }
> >  
> > -static int restore_links()
> > +static int restore_master_link(int nlsk, struct ns_id *ns, struct net_link *link)
> > +{
> > +	struct newlink_req req;
> > +
> > +	memset(&req, 0, sizeof(req));
> > +
> > +	req.h.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
> > +	req.h.nlmsg_flags = NLM_F_REQUEST|NLM_F_ACK|NLM_F_CREATE;
> > +	req.h.nlmsg_type = RTM_SETLINK;
> > +	req.h.nlmsg_seq = CR_NLMSG_SEQ;
> > +	req.i.ifi_family = AF_PACKET;
> > +	req.i.ifi_index = link->nde->ifindex;
> > +	req.i.ifi_flags = link->nde->flags;
> > +
> > +	addattr_l(&req.h, sizeof(req), IFLA_MASTER,
> > +			&link->nde->master, sizeof(link->nde->master));
> > +
> > +	return do_rtnl_req(nlsk, &req, req.h.nlmsg_len, restore_link_cb, NULL, NULL, NULL);
> 
> This is move_to_bridge() isn't it? Can we factor this out?

move_to_bridge use ioctl-s and does some other actions if_nametoindex(),
changeflags(). Here I know that if we have nsid in namespaces, we can
use netlink messages to add a device to a bridge. Actually it isn't only
about bridge-s. We set a master device, it will work for bondings too.

> 
> > +}
> > +
> > +struct net_link *lookup_net_link(struct ns_id *ns, uint32_t ifindex)
> > +{
> > +	struct net_link *link;
> > +
> > +	list_for_each_entry(link, &ns->net.links, node)
> > +		if (link->nde->ifindex == ifindex)
> > +			return link;
> > +
> > +	return NULL;
> > +}
> > +
> 


More information about the CRIU mailing list