Skip to content

Commit

Permalink
rtbsd: support RTM_IFANNOUNCE messages
Browse files Browse the repository at this point in the history
When devices are created, they are announced using RTM_IFANNOUNCE messages using
PF_ROUTE.

Signed-off-by: Thadeu Lima de Souza Cascardo <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
Thadeu Lima de Souza Cascardo authored and blp committed Aug 2, 2015
1 parent 42d4792 commit f5fb24d
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions lib/rtbsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,15 @@ rtbsd_notifier_run(void)
if (retval >= 0) {
/* received packet from PF_ROUTE socket
* XXX check for bad packets */
if (msg.ifm_type == RTM_IFINFO) {
switch (msg.ifm_type) {
case RTM_IFINFO:
/* Since RTM_IFANNOUNCE messages are smaller than RTM_IFINFO
* messages, the same buffer may be used. */
case RTM_IFANNOUNCE:
rtbsd_report_change(&msg);
break;
default:
break;
}
} else if (errno == EAGAIN) {
ovs_mutex_unlock(&rtbsd_mutex);
Expand Down Expand Up @@ -161,14 +168,25 @@ rtbsd_report_change(const struct if_msghdr *msg)
{
struct rtbsd_notifier *notifier;
struct rtbsd_change change;
const struct if_announcemsghdr *ahdr;

COVERAGE_INC(rtbsd_changed);

change.msg_type = msg->ifm_type; //XXX
change.if_index = msg->ifm_index;
if_indextoname(msg->ifm_index, change.if_name);
change.master_ifindex = 0; //XXX

switch (msg->ifm_type) {
case RTM_IFINFO:
change.if_index = msg->ifm_index;
if_indextoname(msg->ifm_index, change.if_name);
break;
case RTM_IFANNOUNCE:
ahdr = (const struct if_announcemsghdr *) msg;
change.if_index = ahdr->ifan_index;
strncpy(change.if_name, ahdr->ifan_name, IF_NAMESIZE);
break;
}

LIST_FOR_EACH (notifier, node, &all_notifiers) {
notifier->cb(&change, notifier->aux);
}
Expand Down

0 comments on commit f5fb24d

Please sign in to comment.