summaryrefslogtreecommitdiff
path: root/accel-pppd/libnetlink
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2016-04-04 14:17:25 +0300
committerDmitry Kozlov <xeb@mail.ru>2016-04-04 14:17:25 +0300
commit581d4533cee479516132a089844b7fc6c32b59ae (patch)
treef1610e0c43c958fe53769c2d60254ae382bea4d5 /accel-pppd/libnetlink
parentb29c9326c2630a0375a9d92b0c553b6e60c8cdaa (diff)
downloadaccel-ppp-581d4533cee479516132a089844b7fc6c32b59ae.tar.gz
accel-ppp-581d4533cee479516132a089844b7fc6c32b59ae.zip
ipoe,pppoe,vlan_mon: deleted conditions to simultaneous start ipoe and pppoe on same interfaces (started by vlan_mon)
Diffstat (limited to 'accel-pppd/libnetlink')
-rw-r--r--accel-pppd/libnetlink/iputils.c19
-rw-r--r--accel-pppd/libnetlink/iputils.h4
-rw-r--r--accel-pppd/libnetlink/libnetlink.c3
3 files changed, 21 insertions, 5 deletions
diff --git a/accel-pppd/libnetlink/iputils.c b/accel-pppd/libnetlink/iputils.c
index e9b82857..ee536744 100644
--- a/accel-pppd/libnetlink/iputils.c
+++ b/accel-pppd/libnetlink/iputils.c
@@ -72,7 +72,9 @@ static int store_nlmsg(const struct sockaddr_nl *who, struct nlmsghdr *n, void *
{
struct ifinfomsg *ifi = NLMSG_DATA(n);
struct rtattr *tb[IFLA_MAX + 1];
+ struct rtattr *tb2[IFLA_MAX + 1];
struct arg *a = arg;
+ int vid = 0, iflink = 0;
if (n->nlmsg_type != RTM_NEWLINK)
return 0;
@@ -86,9 +88,19 @@ static int store_nlmsg(const struct sockaddr_nl *who, struct nlmsghdr *n, void *
if (tb[IFLA_IFNAME] == NULL)
return 0;
+ if (tb[IFLA_LINKINFO]) {
+ parse_rtattr_nested(tb2, IFLA_MAX, tb[IFLA_LINKINFO]);
+ if (!strcmp(RTA_DATA(tb2[IFLA_INFO_KIND]), "vlan")) {
+ parse_rtattr_nested(tb2, IFLA_MAX, tb2[IFLA_INFO_DATA]);
+ vid = *(uint16_t *)RTA_DATA(tb2[IFLA_VLAN_ID]);
+ }
+ }
+
+ if (tb[IFLA_LINK])
+ iflink = *(int *)RTA_DATA(tb[IFLA_LINK]);
//printf("%i %s\n", ifi->ifi_index, RTA_DATA(tb[IFLA_IFNAME]));
- return a->func(ifi->ifi_index, ifi->ifi_flags, RTA_DATA(tb[IFLA_IFNAME]), a->arg);
+ return a->func(ifi->ifi_index, ifi->ifi_flags, RTA_DATA(tb[IFLA_IFNAME]), iflink, vid, a->arg);
}
int __export iplink_list(iplink_list_func func, void *arg)
@@ -250,7 +262,7 @@ int __export iplink_vlan_del(int ifindex)
return 0;
}
-int __export iplink_vlan_get_vid(int ifindex)
+int __export iplink_vlan_get_vid(int ifindex, int *iflink)
{
struct iplink_req {
struct nlmsghdr n;
@@ -294,6 +306,9 @@ int __export iplink_vlan_get_vid(int ifindex)
if (!tb[IFLA_LINKINFO])
return 0;
+ if (iflink && tb[IFLA_LINK])
+ *iflink = *(int *)RTA_DATA(tb[IFLA_LINK]);
+
parse_rtattr_nested(tb, IFLA_MAX, tb[IFLA_LINKINFO]);
if (strcmp(RTA_DATA(tb[IFLA_INFO_KIND]), "vlan"))
diff --git a/accel-pppd/libnetlink/iputils.h b/accel-pppd/libnetlink/iputils.h
index 1ce04103..d5f9701d 100644
--- a/accel-pppd/libnetlink/iputils.h
+++ b/accel-pppd/libnetlink/iputils.h
@@ -3,14 +3,14 @@
#include <linux/if_link.h>
-typedef int (*iplink_list_func)(int index, int flags, const char *name, void *arg);
+typedef int (*iplink_list_func)(int index, int flags, const char *name, int iflink, int vid, void *arg);
int iplink_list(iplink_list_func func, void *arg);
int iplink_get_stats(int ifindex, struct rtnl_link_stats *stats);
int iplink_vlan_add(const char *ifname, int ifindex, int vid);
int iplink_vlan_del(int ifindex);
-int iplink_vlan_get_vid(int ifindex);
+int iplink_vlan_get_vid(int ifindex, int *iflink);
int ipaddr_add(int ifindex, in_addr_t addr, int mask);
int ipaddr_del(int ifindex, in_addr_t addr, int mask);
diff --git a/accel-pppd/libnetlink/libnetlink.c b/accel-pppd/libnetlink/libnetlink.c
index 0536783a..aca16aff 100644
--- a/accel-pppd/libnetlink/libnetlink.c
+++ b/accel-pppd/libnetlink/libnetlink.c
@@ -382,7 +382,8 @@ int __export rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
memcpy(answer, h, h->nlmsg_len);
return 0;
}
- log_debug("libnetlink: ""RTNETLINK answers: %s\n", strerror(errno));
+ if (!ignore_einval)
+ log_debug("libnetlink: ""RTNETLINK answers: %s\n", strerror(errno));
}
return -1;
}