On 01/31/2011 11:31 AM, Mark Rustad wrote:
+#ifdef Linux

We only support linux now and this file was used for all OSs so you can just remove the ifdefs.


+static int select_priority(iscsi_conn_t *conn, int pri_mask)

I have been trying to move away from the iscsi_conn_t and just use struct iscsi_conn.


+
+#ifdef Linux
+       int pri_mask = 0;
+
+       if (conn->session->netdev[0])
+               pri_mask = get_dcb_app_pri_by_port(conn->session->netdev,
+                                               ISCSI_DEFAULT_PORT);

The problem with doing this here is that we have 2 modes:

1. iscsi layer uses socket layer like a normal boring application where it just uses the default routing. In this mode we netdev is not set to a valid interface here, because we do not know what interface the routing is going to take us through at this point. We are just a dumb app and do not care, and rely on the network admin to set things up correctly.

Your patch will not work with this mode.

Solution:?

- Can we do the SO_PRIORITY sockopt after we are connected? If so then after we connect can we do something like getsockname() to figure out what netdevice the socket using. Would we go getsockname to get the addr then do if_nameindex or getifaddrs to match the address with a nic?

Would we do this in iscsi_io_tcp_poll then poll indicates we are logged in?


If we have to do SO_PRIORITY before connect() then would we have to look through the routing table and figure out what is going to be used?


2. iscsi layer will bind the socket to a specific interface. In this case the netdev is set to a valid interface and bind_conn_to_iface() calls setsockopt SO_BINDTODEVICE to tell network layer to forget routing and use what we tell it (if it wrong and there is not valid route then we just fail, so the user has to know what they are doing).

Your patch should work ok with this mode.


+       if (pri_mask<  0)
+               log_debug(2, "Getting priority for %s returned %d",
+                               conn->session->netdev, pri_mask);
+       else if (pri_mask == 0)
+               log_debug(2, "No priority for %s", conn->session->netdev);
+       else {
+               int pri = select_priority(conn, pri_mask);
+
+               log_debug(1, "Setting socket priority to %d", pri);
+               rc = setsockopt(conn->socket_fd, SOL_SOCKET,
+                               SO_PRIORITY,&pri, sizeof(pri));
+       }
+#endif /* Linux */
+
        rc = connect(conn->socket_fd, (struct sockaddr *) ss, sizeof (*ss));
        return rc;
  }


--
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.

Reply via email to