aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorswarupn <swarupnpvt@gmail.com>2018-11-02 17:54:07 +0530
committeryalei wang <wylandrea@gmail.com>2018-11-05 07:07:09 +0000
commit225db1966cfdc3ca0a9e4e913ec66f6e52cf2d47 (patch)
tree8a99491a5ae2de7cb6a6eba27ded19eb401b48e2
parent5f151f3a37a33379626c6fd7fb3062d1b898c0ee (diff)
Fix: Ip route RD has higher priority than protocol route for now. v18.10
RD resloution move to bind/connect. Change-Id: I1224233c488db41d3655d986b22ac00b819329cb Signed-off-by: swarupn <swarupnpvt@gmail.com>
-rw-r--r--src/nSocket/nstack/nstack_socket.c95
-rw-r--r--src/nSocket/nstack_rd/nstack_rd_ip.c7
2 files changed, 81 insertions, 21 deletions
diff --git a/src/nSocket/nstack/nstack_socket.c b/src/nSocket/nstack/nstack_socket.c
index c967d64..210e29d 100644
--- a/src/nSocket/nstack/nstack_socket.c
+++ b/src/nSocket/nstack/nstack_socket.c
@@ -141,12 +141,10 @@ int
nstack_socket (int domain, int itype, int protocol)
{
int ret = -1; //tmp ret of a Single proctol mode.
- int rdret = -1; //the final Return judge vale.
int modInx;
nstack_socket_ops *ops;
int ret_fd = -1;
int protoFD[NSTACK_MAX_MODULE_NUM];
- nstack_rd_key rdkey = { 0 };
int selectmod = -1;
/*check whether module init finish or not */
@@ -183,22 +181,6 @@ nstack_socket (int domain, int itype, int protocol)
nstack_fd_local_lock_info_t *lock_info = get_fd_local_lock_info (ret_fd);
LOCK_FOR_EP (lock_info);
-
- /*check wether select stack create success, if no return fail */
- rdkey.type = RD_DATA_TYPE_PROTO;
- rdkey.proto_type = itype;
- rdret = nstack_rd_get_stackid (&rdkey, &selectmod);
- if ((0 != rdret) || (selectmod < 0) || (selectmod >= nstack_get_modNum ()))
- {
- NSSOC_LOGERR ("protocol:%d select stack fail", protocol);
- selectmod = -1;
- }
- else
- {
- NSSOC_LOGINF ("Create socket of]select modName=%s",
- nstack_get_module_name_by_idx (selectmod));
- }
-
/*create socket by calling select module or all module */
nstack_each_modOps (modInx, ops)
{
@@ -389,6 +371,26 @@ nstack_bind (int fd, const struct sockaddr *addr, socklen_t addrlen)
nstack_get_module_name_by_idx (selectmod));
}
+ if (selectmod == -1)
+ {
+ rdkey.type = RD_DATA_TYPE_PROTO;
+ rdkey.proto_type = fdInf->type;
+ retval = nstack_rd_get_stackid (&rdkey, &selectmod);
+ if ((0 != retval) || (selectmod < 0)
+ || (selectmod >= nstack_get_modNum ()))
+ {
+ NSSOC_LOGWAR
+ ("fd Can't select any module for]fd=%d,IP==%s using proto route",
+ fd, inet_ntoa ((iaddr->sin_addr)));
+ selectmod = -1;
+ }
+ else
+ {
+ NSSOC_LOGINF ("Bind socket of]select modName=%s",
+ nstack_get_module_name_by_idx (selectmod));
+ }
+ }
+
retval = -1;
nstack_each_modInx (modIdx)
{
@@ -902,6 +904,25 @@ nstack_connect (int fd, const struct sockaddr *addr, socklen_t addrlen)
rdkey.type = RD_DATA_TYPE_IP;
rdkey.ip_addr = iaddr->sin_addr.s_addr;
retval = nstack_rd_get_stackid (&rdkey, &selectmod);
+ if ((0 != retval) || (selectmod == -1))
+ {
+ rdkey.type = RD_DATA_TYPE_PROTO;
+ rdkey.proto_type = fdInf->type;
+ retval = nstack_rd_get_stackid (&rdkey, &selectmod);
+ if ((0 != retval) || (selectmod < 0)
+ || (selectmod >= nstack_get_modNum ()))
+ {
+ NSSOC_LOGINF ("fd=%d addr=%s Select module=%s",
+ fd, inet_ntoa (iaddr->sin_addr),
+ nstack_get_module_name_by_idx (selectmod));
+ selectmod = -1;
+ }
+ else
+ {
+ NSSOC_LOGINF ("Connect socket of]select modName=%s",
+ nstack_get_module_name_by_idx (selectmod));
+ }
+ }
if (ns_success == retval && selectmod >= 0)
{
NSSOC_LOGINF ("fd=%d addr=%s Select module=%s",
@@ -1385,6 +1406,25 @@ nstack_sendto (int fd, const void *buf, size_t len, int flags,
rdkey.type = RD_DATA_TYPE_IP;
rdkey.ip_addr = iaddr->sin_addr.s_addr;
retval = nstack_rd_get_stackid (&rdkey, &selectmod);
+ if ((0 != retval) || (selectmod == -1))
+ {
+ rdkey.type = RD_DATA_TYPE_PROTO;
+ rdkey.proto_type = fdInf->type;
+ retval = nstack_rd_get_stackid (&rdkey, &selectmod);
+ if ((0 != retval) || (selectmod < 0)
+ || (selectmod >= nstack_get_modNum ()))
+ {
+ NSSOC_LOGINF ("fd=%d addr=%s Select module=%s",
+ fd, inet_ntoa (iaddr->sin_addr),
+ nstack_get_module_name_by_idx (selectmod));
+ selectmod = -1;
+ }
+ else
+ {
+ NSSOC_LOGINF ("sendto socket of]select modName=%s",
+ nstack_get_module_name_by_idx (selectmod));
+ }
+ }
if ((ns_success == retval) && (selectmod >= 0))
{
NSSOC_LOGINF ("fd=%d,addr=%s,select_module=%s",
@@ -1472,6 +1512,25 @@ nstack_sendmsg (int fd, const struct msghdr * msg, int flags)
rdkey.type = RD_DATA_TYPE_IP;
rdkey.ip_addr = iaddr->sin_addr.s_addr;
retval = nstack_rd_get_stackid (&rdkey, &selectmod);
+ if ((0 != retval) || (selectmod == -1))
+ {
+ rdkey.type = RD_DATA_TYPE_PROTO;
+ rdkey.proto_type = fdInf->type;
+ retval = nstack_rd_get_stackid (&rdkey, &selectmod);
+ if ((0 != retval) || (selectmod < 0)
+ || (selectmod >= nstack_get_modNum ()))
+ {
+ NSSOC_LOGINF ("fd=%d addr=%s Select module=%s",
+ fd, inet_ntoa (iaddr->sin_addr),
+ nstack_get_module_name_by_idx (selectmod));
+ selectmod = -1;
+ }
+ else
+ {
+ NSSOC_LOGINF ("Connect socket of]select modName=%s",
+ nstack_get_module_name_by_idx (selectmod));
+ }
+ }
if (ns_success == retval)
{
NSSOC_LOGINF ("fd=%d,addr=%s,select_module=%s",
diff --git a/src/nSocket/nstack_rd/nstack_rd_ip.c b/src/nSocket/nstack_rd/nstack_rd_ip.c
index c9246c0..82035d1 100644
--- a/src/nSocket/nstack_rd/nstack_rd_ip.c
+++ b/src/nSocket/nstack_rd/nstack_rd_ip.c
@@ -64,12 +64,13 @@ nstack_rd_ip_item_insert (nstack_rd_list * hlist, void *rditem)
nstack_rd_node *tempdata = NULL;
struct hlist_node *tempnode = NULL;
struct hlist_node *tem = NULL;
- unsigned int ip_addr = 0;
- unsigned int ip_masklen = 0;
- unsigned int ip_maskv = MASK_V (ip_addr, ip_masklen);
+
unsigned int tempip_addr = 0;
unsigned int tempip_masklen = 0;
rd_data_item *pitem = (rd_data_item *) rditem;
+ unsigned int ip_addr = pitem->ipdata.addr;
+ unsigned int ip_masklen = pitem->ipdata.masklen;
+ unsigned int ip_maskv = MASK_V (ip_addr, ip_masklen);
ip_masklen = pitem->ipdata.masklen;
NSSOC_LOGDBG ("stackid:%d, ipaddr:%u.%u.%u.%u masklen:0x%x was inserted",