[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAHA+R7Njnb8DZOq6dF7sktFgQYOOAY+JiiToh62B2C9SXroO3g@mail.gmail.com>
Date: Tue, 4 Aug 2015 21:26:48 -0700
From: Cong Wang <cwang@...pensource.com>
To: Sowmini Varadhan <sowmini.varadhan@...cle.com>
Cc: netdev <netdev@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
David Miller <davem@...emloft.net>, rds-devel@....oracle.com,
ajaykumar.hotchandani@...cle.com, igor.maximov@...cle.com,
chien.yen@...cle.com
Subject: Re: [PATCH v2 net-next 2/2] RDS-TCP: Support multiple RDS-TCP listen
endpoints, one per netns.
On Mon, Aug 3, 2015 at 10:29 PM, Sowmini Varadhan
<sowmini.varadhan@...cle.com> wrote:
> +static struct pernet_operations rds_tcp_net_ops = {
> + .init = rds_tcp_init_net,
> + .exit = rds_tcp_exit_net,
> + .id = &rds_tcp_netid,
> + .size = sizeof(struct rds_tcp_net),
> +};
> +
> +static void rds_tcp_kill_sock(struct net *net)
> +{
> + struct rds_tcp_connection *tc, *_tc;
> + struct sock *sk;
> + struct list_head tmp_list;
> + struct rds_tcp_net *rtn = net_generic(net, rds_tcp_netid);
> +
> + rds_tcp_listen_stop(rtn->rds_tcp_listen_sock);
> + rtn->rds_tcp_listen_sock = NULL;
> + flush_work(&rtn->rds_tcp_accept_w);
> + INIT_LIST_HEAD(&tmp_list);
Can be folded as LIST_HEAD(tmp_list).
> + spin_lock_irq(&rds_tcp_conn_lock);
> + list_for_each_entry_safe(tc, _tc, &rds_tcp_conn_list, t_tcp_node) {
> + struct net *c_net = read_pnet(&tc->conn->c_net);
> +
> + if (net != c_net || !tc->t_sock)
> + continue;
> + list_del(&tc->t_tcp_node);
> + list_add_tail(&tc->t_tcp_node, &tmp_list);
list_move_tail().
> + }
> + spin_unlock_irq(&rds_tcp_conn_lock);
> + list_for_each_entry_safe(tc, _tc, &tmp_list, t_tcp_node) {
> + sk = tc->t_sock->sk;
> + sk->sk_prot->disconnect(sk, 0);
> + tcp_done(sk);
> + if (tc->conn->c_passive)
> + rds_conn_destroy(tc->conn->c_passive);
> + rds_conn_destroy(tc->conn);
> + }
> +}
> +
> +static int rds_tcp_dev_event(struct notifier_block *this,
> + unsigned long event, void *ptr)
> +{
> + struct net_device *dev = netdev_notifier_info_to_dev(ptr);
> +
> + /* rds-tcp registers as a pernet subys, so the ->exit will only
> + * get invoked after network acitivity has quiesced. We need to
> + * clean up all sockets to quiesce network activity, and use
> + * the unregistration of the per-net loopback device as a trigger
> + * to start that cleanup.
> + */
> + if (event == NETDEV_UNREGISTER_FINAL &&
> + strcmp(dev->name, "lo") == 0)
Shouldn't check device name, check ->ifindex == LOOPBACK_IFINDEX
instead.
> + rds_tcp_kill_sock(dev_net(dev));
> +
> + return NOTIFY_DONE;
> +}
> +
...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists