Skip to content

Commit 37b8dc1

Browse files
jukkarcarlescufi
authored andcommitted
net: socket: Allow same port if different address family
It is always possible to bind to same port if the sockets are in different address family. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
1 parent 12720fe commit 37b8dc1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

subsys/net/ip/net_context.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ static int check_used_port(enum net_ip_protocol proto,
132132

133133
if (IS_ENABLED(CONFIG_NET_IPV6) &&
134134
local_addr->sa_family == AF_INET6) {
135-
if (net_sin6_ptr(&contexts[i].local)->sin6_addr == NULL) {
135+
if (net_sin6_ptr(&contexts[i].local)->sin6_addr == NULL ||
136+
net_sin6_ptr(&contexts[i].local)->sin6_family != AF_INET6) {
136137
continue;
137138
}
138139

@@ -187,7 +188,8 @@ static int check_used_port(enum net_ip_protocol proto,
187188
}
188189
} else if (IS_ENABLED(CONFIG_NET_IPV4) &&
189190
local_addr->sa_family == AF_INET) {
190-
if (net_sin_ptr(&contexts[i].local)->sin_addr == NULL) {
191+
if (net_sin_ptr(&contexts[i].local)->sin_addr == NULL ||
192+
net_sin_ptr(&contexts[i].local)->sin_family != AF_INET) {
191193
continue;
192194
}
193195

0 commit comments

Comments
 (0)