Merge pull request #15370 from YannCharbon/sockopt_interface_id

Fix socket default interface ID only being used partially
pull/15378/head
Martin Kojtal 2023-01-16 15:44:59 +00:00 committed by GitHub
commit a852898ad1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -1570,8 +1570,17 @@ struct protocol_interface_info_entry *socket_interface_determine(const socket_t
}
}
/* Try a routing table entry for greater-than-realm scope */
/* For greater-than-realm scope, use default interface if a default interface ID */
/* has been set (e.g. using setsockopt), else try a routing table entry */
if (addr_ipv6_scope(buf->dst_sa.address, NULL) > IPV6_SCOPE_REALM_LOCAL) {
if (socket_ptr->default_interface_id != -1) {
cur_interface = protocol_stack_interface_info_get_by_id(socket_ptr->default_interface_id);
if (cur_interface) {
return cur_interface;
} else {
return NULL;
}
}
if (ipv6_buffer_route(buf)) {
return buf->interface;
}