session: store tep port in net order 65/8465/3
authorFlorin Coras <fcoras@cisco.com>
Wed, 20 Sep 2017 05:27:18 +0000 (22:27 -0700)
committerDave Wallace <dwallacelf@gmail.com>
Wed, 20 Sep 2017 17:50:48 +0000 (17:50 +0000)
Change-Id: Ie3a99f09f44ec081d9b88a213bdb8d987fb462de
Signed-off-by: Florin Coras <fcoras@cisco.com>
src/vnet/session/application_interface.c
src/vnet/session/transport.h
src/vnet/tcp/tcp.c
src/vnet/udp/udp.c

index 8dbc3a1..7e7449a 100644 (file)
@@ -92,9 +92,7 @@ vnet_bind_i (u32 app_index, session_type_t sst,
       return VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
     }
 
-  listener = stream_session_lookup_listener (&tep->ip,
-                                            clib_host_to_net_u16 (tep->port),
-                                            sst);
+  listener = stream_session_lookup_listener (&tep->ip, tep->port, sst);
   if (listener)
     return VNET_API_ERROR_ADDRESS_IN_USE;
 
@@ -131,9 +129,7 @@ vnet_connect_i (u32 app_index, u32 api_context, session_type_t sst,
   /*
    * Figure out if connecting to a local server
    */
-  listener = stream_session_lookup_listener (&tep->ip,
-                                            clib_host_to_net_u16 (tep->port),
-                                            sst);
+  listener = stream_session_lookup_listener (&tep->ip, tep->port, sst);
   if (listener)
     {
       server = application_get (listener->app_index);
@@ -181,6 +177,7 @@ unformat_vnet_uri (unformat_input_t * input, va_list * args)
                &tep->port))
     {
       *sst = SESSION_TYPE_IP4_TCP;
+      tep->port = clib_host_to_net_u16 (tep->port);
       tep->is_ip4 = 1;
       return 1;
     }
@@ -188,6 +185,7 @@ unformat_vnet_uri (unformat_input_t * input, va_list * args)
                &tep->port))
     {
       *sst = SESSION_TYPE_IP4_UDP;
+      tep->port = clib_host_to_net_u16 (tep->port);
       tep->is_ip4 = 1;
       return 1;
     }
@@ -195,12 +193,14 @@ unformat_vnet_uri (unformat_input_t * input, va_list * args)
                &tep->port))
     {
       *sst = SESSION_TYPE_IP6_UDP;
+      tep->port = clib_host_to_net_u16 (tep->port);
       return 1;
     }
   if (unformat (input, "tcp://%U/%d", unformat_ip6_address, &tep->ip.ip6,
                &tep->port))
     {
       *sst = SESSION_TYPE_IP6_TCP;
+      tep->port = clib_host_to_net_u16 (tep->port);
       return 1;
     }
 
index e56be33..e2c4794 100644 (file)
@@ -78,7 +78,7 @@ typedef enum _transport_proto
 typedef struct _transport_endpoint
 {
   ip46_address_t ip;   /** ip address */
-  u16 port;            /** port in host order */
+  u16 port;            /** port in net order */
   u8 is_ip4;           /** 1 if ip4 */
   u32 vrf;             /** fib table the endpoint is associated with */
 } transport_endpoint_t;
index d43fb14..38a21db 100644 (file)
@@ -38,7 +38,7 @@ tcp_connection_bind (u32 session_index, transport_endpoint_t * lcl)
   memset (listener, 0, sizeof (*listener));
 
   listener->c_c_index = listener - tm->listener_pool;
-  listener->c_lcl_port = clib_host_to_net_u16 (lcl->port);
+  listener->c_lcl_port = lcl->port;
 
   if (lcl->is_ip4)
     {
@@ -701,7 +701,7 @@ tcp_connection_open (transport_endpoint_t * rmt)
   tc = tcp_half_open_connection_new ();
   clib_memcpy (&tc->c_rmt_ip, &rmt->ip, sizeof (ip46_address_t));
   clib_memcpy (&tc->c_lcl_ip, &lcl_addr, sizeof (ip46_address_t));
-  tc->c_rmt_port = clib_host_to_net_u16 (rmt->port);
+  tc->c_rmt_port = rmt->port;
   tc->c_lcl_port = clib_host_to_net_u16 (lcl_port);
   tc->c_is_ip4 = rmt->is_ip4;
   tc->c_transport_proto = TRANSPORT_PROTO_TCP;
index fedf2cc..0e0336b 100644 (file)
@@ -32,11 +32,11 @@ udp_session_bind_ip4 (u32 session_index, transport_endpoint_t * lcl)
 
   pool_get (um->udp_listeners, listener);
   memset (listener, 0, sizeof (udp_connection_t));
-  listener->c_lcl_port = clib_host_to_net_u16 (lcl->port);
+  listener->c_lcl_port = lcl->port;
   listener->c_lcl_ip4.as_u32 = lcl->ip.ip4.as_u32;
   listener->c_transport_proto = TRANSPORT_PROTO_UDP;
-  udp_register_dst_port (um->vlib_main, lcl->port, udp4_uri_input_node.index,
-                        1 /* is_ipv4 */ );
+  udp_register_dst_port (um->vlib_main, clib_net_to_host_u16 (lcl->port),
+                        udp4_uri_input_node.index, 1 /* is_ipv4 */ );
   return 0;
 }
 
@@ -47,10 +47,10 @@ udp_session_bind_ip6 (u32 session_index, transport_endpoint_t * lcl)
   udp_connection_t *listener;
 
   pool_get (um->udp_listeners, listener);
-  listener->c_lcl_port = clib_host_to_net_u16 (lcl->port);
+  listener->c_lcl_port = lcl->port;
   clib_memcpy (&listener->c_lcl_ip6, &lcl->ip.ip6, sizeof (ip6_address_t));
   listener->c_transport_proto = TRANSPORT_PROTO_UDP;
-  udp_register_dst_port (um->vlib_main, lcl->port,
+  udp_register_dst_port (um->vlib_main, clib_net_to_host_u16 (lcl->port),
                         udp4_uri_input_node.index, 0 /* is_ipv4 */ );
   return 0;
 }