Hi Dan, On 10/02/10 9:55 -0800, Dan Smith wrote: > Guilt dropped the new checkpoint_dev.c file when I switched to the > newer branch. Sorry about that. Updated patch included below. > [...] > diff --git a/net/checkpoint_dev.c b/net/checkpoint_dev.c > new file mode 100644 > index 0000000..0dddd15 > --- /dev/null > +++ b/net/checkpoint_dev.c [...] > + > +static struct nlmsghdr *rtnl_get_response(struct socket *rtnl, > + struct sk_buff **skb) > +{ > + int ret; > + long timeo = MAX_SCHEDULE_TIMEOUT; > + struct nlmsghdr *nlh; > + > + ret = sk_wait_data(rtnl->sk, &timeo); > + if (!ret) > + return ERR_PTR(-EPIPE); > + > + *skb = skb_dequeue(&rtnl->sk->sk_receive_queue); > + if (!*skb) > + return ERR_PTR(-EPIPE); > + > + ret = -EINVAL; > + nlh = nlmsg_hdr(*skb); > + if (!nlh) > + goto err; > + > + if (nlh->nlmsg_type == NLMSG_ERROR) { > + struct nlmsgerr *errmsg = nlmsg_data(nlh); > + ret = errmsg->error; > + goto err; > + } > + > + return nlh; > + err: > + kfree_skb(*skb); > + *skb = NULL; > + > + return ERR_PTR(ret); > +} > + [...] > + > +static struct sk_buff *new_link_message(char *this_name, char *peer_name) > +{ > + int ret = -ENOMEM; > + int flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_ACK; > + struct nlmsghdr *nlh; > + struct sk_buff *skb; > + struct ifinfomsg *ifm; > + struct nlattr *linkinfo; > + > + skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); > + if (!skb) > + goto out; > + > + nlh = nlmsg_put(skb, 0, 0, RTM_NEWLINK, sizeof(*ifm), flags); > + if (!nlh) > + goto out; > + > + ifm = nlmsg_data(nlh); > + memset(ifm, 0, sizeof(*ifm)); > + > + ret = nla_put_string(skb, IFLA_IFNAME, this_name); > + if (ret) > + goto out; > + > + ret = -ENOMEM; > + > + linkinfo = nla_nest_start(skb, IFLA_LINKINFO); > + if (!linkinfo) > + goto out; > + > + if (nla_put_string(skb, IFLA_INFO_KIND, "veth") < 0) > + goto out; > + > + ret = veth_peer_data(skb, peer_name); > + if (ret < 0) > + goto out; > + > + nla_nest_end(skb, linkinfo); > + nlmsg_end(skb, nlh); > + > + out: > + if (ret < 0) { > + kfree(skb); I'm definitely not a network expert, but this kfree(skb) should probably be replaced by kfree_skb(skb). > + skb = ERR_PTR(ret); > + } > + > + return skb; > +} > + > +static struct net_device *new_veth_pair(char *this_name, char *peer_name) > +{ > + int ret = -ENOMEM; > + struct socket *rtnl; > + struct sk_buff *skb = NULL; > + struct nlmsghdr *nlh; > + struct msghdr msg; > + struct kvec kvec; > + > + skb = new_link_message(this_name, peer_name); > + if (IS_ERR(skb)) { > + ret = PTR_ERR(skb); > + ckpt_debug("failed to create new link message: %i\n", ret); > + skb = NULL; > + goto out; > + } > + > + memset(&msg, 0, sizeof(msg)); > + kvec.iov_len = skb->len; > + kvec.iov_base = skb->head; > + > + rtnl = rtnl_open(); > + if (IS_ERR(rtnl)) { > + ret = PTR_ERR(rtnl); > + ckpt_debug("Unable to open rtnetlink socket: %i\n", ret); > + goto out_noclose; > + } > + > + ret = kernel_sendmsg(rtnl, &msg, &kvec, 1, kvec.iov_len); > + if (ret < 0) > + goto out; > + else if (ret != skb->len) { > + ret = -EIO; > + goto out; > + } > + > + /* Free the send skb to make room for the receive skb */ > + kfree(skb); Ditto. > + > + nlh = rtnl_get_response(rtnl, &skb); > + if (IS_ERR(nlh)) { > + ret = PTR_ERR(nlh); > + ckpt_debug("RTNETLINK said: %i\n", ret); > + } > + out: > + rtnl_close(rtnl); > + out_noclose: > + kfree(skb); Ditto. Thanks, Louis [...] -- Dr Louis Rilling Kerlabs Skype: louis.rilling Batiment Germanium Phone: (+33|0) 6 80 89 08 23 80 avenue des Buttes de Coesmes http://www.kerlabs.com/ 35700 Rennes
Attachment:
signature.asc
Description: Digital signature
_______________________________________________ Containers mailing list Containers@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linux-foundation.org/mailman/listinfo/containers