On Wed, 2015-11-18 at 10:52 +0900, Lorenzo Colitti wrote: > > +static int kill_inet_sock(const struct sockaddr_nl *addr, > + struct nlmsghdr *h, void *arg) > +{ > + struct rtnl_handle rth; > + if (rtnl_open_byproto(&rth, 0, NETLINK_SOCK_DIAG)) > + return -1; > + > + struct inet_diag_arg *diag_arg = arg; > + struct inet_diag_msg *d = NLMSG_DATA(h); > + DIAG_REQUEST(req, struct inet_diag_req_v2 r); > + req.nlh.nlmsg_type = SOCK_DESTROY; > + req.nlh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; > + req.r.sdiag_family = d->idiag_family; > + req.r.sdiag_protocol = diag_arg->protocol; > + req.r.id = d->id; > + > + int err = rtnl_talk(&rth, &req.nlh, NULL, 0); > + rtnl_close(&rth); > + return err; > +}
1) Please do not mix variables and code. 2) opening/closing a control socket for every killed TCP socket is going to consume a lot of cpu cycles. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html