Skip to content

Commit

Permalink
Add interface to egress group if it has default route
Browse files Browse the repository at this point in the history
  • Loading branch information
mekanix committed Jul 31, 2022
1 parent fc952ac commit afeff25
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions sys/net/route/route_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1256,9 +1256,23 @@ rib_action(uint32_t fibnum, int action, struct rt_addrinfo *info,
{
int error;


switch (action) {
case RTM_ADD:
error = rib_add_route(fibnum, info, rc);
if (!error && info->rti_ifp) {
struct sockaddr *dst = info->rti_info[RTAX_DST];
if (dst->sa_family == AF_INET) {
char ip[INET6_ADDRSTRLEN > INET_ADDRSTRLEN ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN];
struct sockaddr_in *addr_in = (struct sockaddr_in *)dst;
inet_ntop(AF_INET, &(addr_in->sin_addr), ip, INET_ADDRSTRLEN);
const char *default_ip = "0.0.0.0";
int len = strlen(default_ip);
if (strncmp(ip, default_ip, len) == 0) {
if_addgroup(info->rti_ifp, IFG_EGRESS);
}
}
}
break;
case RTM_DELETE:
error = rib_del_route(fibnum, info, rc);
Expand Down

0 comments on commit afeff25

Please sign in to comment.