-int
-ksocknal_push (lnet_ni_t *ni, lnet_process_id_t id)
-{
- ksock_peer_t *peer;
- cfs_list_t *tmp;
- int index;
- int i;
- int j;
- int rc = -ENOENT;
-
- for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) {
- for (j = 0; ; j++) {
- read_lock(&ksocknal_data.ksnd_global_lock);
-
- index = 0;
- peer = NULL;
-
- cfs_list_for_each (tmp, &ksocknal_data.ksnd_peers[i]) {
- peer = cfs_list_entry(tmp, ksock_peer_t,
- ksnp_list);
-
- if (!((id.nid == LNET_NID_ANY ||
- id.nid == peer->ksnp_id.nid) &&
- (id.pid == LNET_PID_ANY ||
- id.pid == peer->ksnp_id.pid))) {
- peer = NULL;
- continue;
- }
-
- if (index++ == j) {
- ksocknal_peer_addref(peer);
- break;
- }
- }
-
- read_unlock(&ksocknal_data.ksnd_global_lock);
-
- if (peer != NULL) {
- rc = 0;
- ksocknal_push_peer (peer);
- ksocknal_peer_decref(peer);
- }
- }
-
- }
-
- return (rc);
-}
-
-int
-ksocknal_add_interface(lnet_ni_t *ni, __u32 ipaddress, __u32 netmask)
-{
- ksock_net_t *net = ni->ni_data;
- ksock_interface_t *iface;
- int rc;
- int i;
- int j;
- cfs_list_t *ptmp;
- ksock_peer_t *peer;
- cfs_list_t *rtmp;
- ksock_route_t *route;
-
- if (ipaddress == 0 ||
- netmask == 0)
- return (-EINVAL);
-
- write_lock_bh(&ksocknal_data.ksnd_global_lock);
-
- iface = ksocknal_ip2iface(ni, ipaddress);
- if (iface != NULL) {
- /* silently ignore dups */
- rc = 0;
- } else if (net->ksnn_ninterfaces == LNET_MAX_INTERFACES) {
- rc = -ENOSPC;
- } else {
- iface = &net->ksnn_interfaces[net->ksnn_ninterfaces++];
-
- iface->ksni_ipaddr = ipaddress;
- iface->ksni_netmask = netmask;
- iface->ksni_nroutes = 0;
- iface->ksni_npeers = 0;
-
- for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) {
- cfs_list_for_each(ptmp, &ksocknal_data.ksnd_peers[i]) {
- peer = cfs_list_entry(ptmp, ksock_peer_t,
- ksnp_list);
-
- for (j = 0; j < peer->ksnp_n_passive_ips; j++)
- if (peer->ksnp_passive_ips[j] == ipaddress)
- iface->ksni_npeers++;
-
- cfs_list_for_each(rtmp, &peer->ksnp_routes) {
- route = cfs_list_entry(rtmp,
- ksock_route_t,
- ksnr_list);
-
- if (route->ksnr_myipaddr == ipaddress)
- iface->ksni_nroutes++;
- }
- }
- }
-
- rc = 0;
- /* NB only new connections will pay attention to the new interface! */
- }
-
- write_unlock_bh(&ksocknal_data.ksnd_global_lock);
-
- return (rc);
-}
-
-void
-ksocknal_peer_del_interface_locked(ksock_peer_t *peer, __u32 ipaddr)
-{
- cfs_list_t *tmp;
- cfs_list_t *nxt;
- ksock_route_t *route;
- ksock_conn_t *conn;
- int i;
- int j;
-
- for (i = 0; i < peer->ksnp_n_passive_ips; i++)
- if (peer->ksnp_passive_ips[i] == ipaddr) {
- for (j = i+1; j < peer->ksnp_n_passive_ips; j++)
- peer->ksnp_passive_ips[j-1] =
- peer->ksnp_passive_ips[j];
- peer->ksnp_n_passive_ips--;
- break;
- }
-
- cfs_list_for_each_safe(tmp, nxt, &peer->ksnp_routes) {
- route = cfs_list_entry (tmp, ksock_route_t, ksnr_list);
-
- if (route->ksnr_myipaddr != ipaddr)
- continue;
-
- if (route->ksnr_share_count != 0) {
- /* Manually created; keep, but unbind */
- route->ksnr_myipaddr = 0;
- } else {
- ksocknal_del_route_locked(route);
- }
- }
-
- cfs_list_for_each_safe(tmp, nxt, &peer->ksnp_conns) {
- conn = cfs_list_entry(tmp, ksock_conn_t, ksnc_list);
-
- if (conn->ksnc_myipaddr == ipaddr)
- ksocknal_close_conn_locked (conn, 0);
- }
-}
-
-int
-ksocknal_del_interface(lnet_ni_t *ni, __u32 ipaddress)