[sr-dev] git:master:a3e80032: core: store advertise addr for new sockets created from interface name

Daniel-Constantin Mierla miconda at gmail.com
Thu Aug 10 14:06:10 CEST 2017


Module: kamailio
Branch: master
Commit: a3e8003274ded1420d2af677246a48ef5c743a3c
URL: https://github.com/kamailio/kamailio/commit/a3e8003274ded1420d2af677246a48ef5c743a3c

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-08-10T14:05:13+02:00

core: store advertise addr for new sockets created from interface name

- reported by GH #1209

---

Modified: src/core/socket_info.c

---

Diff:  https://github.com/kamailio/kamailio/commit/a3e8003274ded1420d2af677246a48ef5c743a3c.diff
Patch: https://github.com/kamailio/kamailio/commit/a3e8003274ded1420d2af677246a48ef5c743a3c.patch

---

diff --git a/src/core/socket_info.c b/src/core/socket_info.c
index ee33d915f4..a50cfe3e59 100644
--- a/src/core/socket_info.c
+++ b/src/core/socket_info.c
@@ -1353,13 +1353,15 @@ static int fix_hostname(str* name, struct ip_addr* address, str* address_str,
  * return 0 on succes, -1 on error
  */
 static int addr_info_to_si_lst(struct addr_info* ai_lst, unsigned short port,
-								char proto, enum si_flags flags,
+								char proto, char *usename,
+								unsigned short useport,
+								enum si_flags flags,
 								struct socket_info** list)
 {
 	struct addr_info* ail;
 	
 	for (ail=ai_lst; ail; ail=ail->next){
-		if(new_sock2list(ail->name.s, 0, port, proto, 0, 0,
+		if(new_sock2list(ail->name.s, 0, port, proto, usename, useport,
 					ail->flags | flags, list)==0)
 			return -1;
 	}
@@ -1374,7 +1376,10 @@ static int addr_info_to_si_lst(struct addr_info* ai_lst, unsigned short port,
  */
 static int addr_info_to_si_lst_after(struct addr_info* ai_lst,
 										unsigned short port,
-										char proto, enum si_flags flags,
+										char proto,
+										char *usename,
+										unsigned short useport,
+										enum si_flags flags,
 										struct socket_info* el)
 {
 	struct addr_info* ail;
@@ -1382,7 +1387,7 @@ static int addr_info_to_si_lst_after(struct addr_info* ai_lst,
 	
 	for (ail=ai_lst; ail; ail=ail->next){
 		if((new_si=new_sock2list_after(ail->name.s, 0, port, proto,
-								0, 0, ail->flags | flags, el))==0)
+								usename, useport, ail->flags | flags, el))==0)
 			return -1;
 		el=new_si;
 	}
@@ -1447,7 +1452,8 @@ static int fix_socket_list(struct socket_info **list, int* type_flags)
 			}else{
 				/* add all addr. as separate  interfaces */
 				if (addr_info_to_si_lst_after(ai_lst, si->port_no, si->proto,
-						 						si->flags, si)!=0)
+							si->useinfo.name.s, si->useinfo.port_no,
+							si->flags, si)!=0)
 					goto error;
 				/* ai_lst not needed anymore */
 				free_addr_info_lst(&ai_lst);
@@ -1758,7 +1764,7 @@ int fix_all_socket_lists()
 #else
 		&& ( !auto_bind_ipv6 || add_interfaces(0, AF_INET6, 0,  PROTO_UDP, &ai_lst) ==0 ) /* add_interface does not work for IPv6 on Linux */
 #endif /* __OS_linux */
-			 ) && (addr_info_to_si_lst(ai_lst, 0, PROTO_UDP, 0, &udp_listen)==0)){
+			 ) && (addr_info_to_si_lst(ai_lst, 0, PROTO_UDP, 0, 0, 0, &udp_listen)==0)){
 			free_addr_info_lst(&ai_lst);
 			ai_lst=0;
 			/* if ok, try to add the others too */
@@ -1770,7 +1776,7 @@ int fix_all_socket_lists()
 #else
 				|| (auto_bind_ipv6 && add_interfaces(0, AF_INET6, 0,  PROTO_TCP, &ai_lst) !=0 )
 #endif /* __OS_linux */
-				) || (addr_info_to_si_lst(ai_lst, 0, PROTO_TCP, 0,
+				) || (addr_info_to_si_lst(ai_lst, 0, PROTO_TCP, 0, 0, 0,
 										 				&tcp_listen)!=0))
 					goto error;
 				free_addr_info_lst(&ai_lst);
@@ -1784,7 +1790,7 @@ int fix_all_socket_lists()
 #else
 				|| (auto_bind_ipv6 && add_interfaces(0, AF_INET6, 0,  PROTO_TLS, &ai_lst)!=0)
 #endif /* __OS_linux */
-					) || (addr_info_to_si_lst(ai_lst, 0, PROTO_TLS, 0,
+					) || (addr_info_to_si_lst(ai_lst, 0, PROTO_TLS, 0, 0, 0,
 										 				&tls_listen)!=0))
 						goto error;
 				}
@@ -1801,7 +1807,7 @@ int fix_all_socket_lists()
 #else
 				|| (auto_bind_ipv6 && add_interfaces(0, AF_INET6, 0,  PROTO_SCTP, &ai_lst) != 0)
 #endif /* __OS_linux */
-					) || (addr_info_to_si_lst(ai_lst, 0, PROTO_SCTP, 0,
+					) || (addr_info_to_si_lst(ai_lst, 0, PROTO_SCTP, 0, 0, 0,
 							 				&sctp_listen)!=0))
 					goto error;
 				free_addr_info_lst(&ai_lst);




More information about the sr-dev mailing list