Skip to content

Commit

Permalink
Merge pull request #1869 from metalefty/bsdunixvlan-group
Browse files Browse the repository at this point in the history
Cedar/VLanUnix: assign virtual interface to softether group
  • Loading branch information
chipitsine committed Aug 7, 2023
2 parents 5d667e4 + 49f8112 commit f6f2660
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Cedar/VLanUnix.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,9 @@ int UnixCreateTapDeviceEx(char *name, char *prefix, UCHAR *mac_address, bool cre
}
#endif

// Set interface group
UnixSetIfGroup(s, tap_name, CEDAR_PRODUCT_STR);

if (create_up)
{
Zero(&ifr, sizeof(ifr));
Expand Down Expand Up @@ -622,6 +625,24 @@ void UnixDestroyClientTapDevice(char *name)
#endif // UNIX_BSD
}

void UnixSetIfGroup(int fd, const char *name, const char *group_name)
{
#ifdef SIOCAIFGROUP
struct ifgroupreq ifgr;
char *tmp;

tmp = CopyStr((char *)group_name);
StrLower(tmp);
Zero(&ifgr, sizeof(ifgr));

StrCpy(ifgr.ifgr_name, sizeof(ifgr.ifgr_name), (char *) name);
StrCpy(ifgr.ifgr_group, sizeof(ifgr.ifgr_group), tmp);
ioctl(fd, SIOCAIFGROUP, &ifgr);

Free(tmp);
#endif
}

#else // NO_VLAN

void UnixCloseDevice(int fd)
Expand All @@ -636,6 +657,10 @@ void UnixDestroyTapDeviceEx(char *name, char *prefix)
{
}

void UnixSetIfGroup()
{
}

int UnixCreateTapDeviceEx(char *name, char *prefix, UCHAR *mac_address, bool create_up)
{
return -1;
Expand Down
1 change: 1 addition & 0 deletions src/Cedar/VLanUnix.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ int UnixCreateTapDeviceEx(char *name, char *prefix, UCHAR *mac_address, bool cre
void UnixCloseTapDevice(int fd);
void UnixDestroyBridgeTapDevice(char *name);
void UnixDestroyClientTapDevice(char *name);
void UnixSetIfGroup(int fd, const char *name, const char *group_name);
void UnixVLanInit();
void UnixVLanFree();
bool UnixVLanCreate(char *name, UCHAR *mac_address, bool create_up);
Expand Down

0 comments on commit f6f2660

Please sign in to comment.