Message ID | 1533216592-12612-1-git-send-email-haifeng.lin@huawei.com |
---|---|
State | Superseded |
Headers | show |
Series | [ovs-dev] netlink-notifier: support blacklist | expand |
Bleep bloop. Greetings Haifeng Lin, I am a robot and I have tried out your patch. Thanks for your contribution. I encountered some error that I wasn't expecting. See the details below. checkpatch: ERROR: Remove Gerrit Change-Id's before submitting upstream. 9: Change-Id: I34121a4c44bfb2fcfe8799130762474bbfe5c015 WARNING: Line has non-spaces leading whitespace #91 FILE: lib/rtnetlink.c:210: rtnetlink_blacklist_init(); WARNING: Line has non-spaces leading whitespace #100 FILE: lib/rtnetlink.c:220: rtnetlink_blacklist_uninit(); ERROR: Improper whitespace around control block #123 FILE: lib/rtnetlink.c:267: CMAP_FOR_EACH(entry, cmap_node, &if_blacklist) { ERROR: Improper whitespace around control block #124 FILE: lib/rtnetlink.c:268: if(entry) { ERROR: Inappropriate spacing in pointer declaration WARNING: Line lacks whitespace around operator #135 FILE: lib/rtnetlink.c:279: rtnetlink_blacklist_add(const char* name) ERROR: Use xstrdup() in place of strdup() #147 FILE: lib/rtnetlink.c:291: entry->name = strdup(name); ERROR: Inappropriate spacing in pointer declaration WARNING: Line lacks whitespace around operator #161 FILE: lib/rtnetlink.c:305: rtnetlink_blacklist_del(const char* name) ERROR: Improper whitespace around control block #189 FILE: lib/rtnetlink.c:333: CMAP_FOR_EACH(entry, cmap_node, &if_blacklist) { ERROR: Improper whitespace around control block #190 FILE: lib/rtnetlink.c:334: if(entry) { WARNING: Line is 81 characters long (recommended limit is 79) #191 FILE: lib/rtnetlink.c:335: if (!strncmp(entry->name, change->ifname, sizeof(*change->ifname))) { ERROR: Inappropriate spacing in pointer declaration WARNING: Line lacks whitespace around operator #214 FILE: lib/rtnetlink.h:81: rtnetlink_blacklist_add(const char* name); ERROR: Inappropriate spacing in pointer declaration WARNING: Line lacks whitespace around operator #221 FILE: lib/rtnetlink.h:88: rtnetlink_blacklist_del(const char* name); Lines checked: 234, Warnings: 7, Errors: 10 build: mv tests/system-dpdk-testsuite.tmp tests/system-dpdk-testsuite \ { sed -n -e '/%AUTHORS%/q' -e p < ./debian/copyright.in; \ sed '34,/^$/d' ./AUTHORS.rst | \ sed -n -e '/^$/q' -e 's/^/ /p'; \ sed -e '34,/%AUTHORS%/d' ./debian/copyright.in; \ } > debian/copyright (printf '\043 Generated automatically -- do not modify! -*- buffer-read-only: t -*-\n' && sed -e 's,[@]VERSION[@],2.10.90,g') < ./rhel/openvswitch-dkms.spec.in > openvswitch-dkms.spec.tmp || exit 1; if cmp -s openvswitch-dkms.spec.tmp rhel/openvswitch-dkms.spec; then touch rhel/openvswitch-dkms.spec; rm openvswitch-dkms.spec.tmp; else mv openvswitch-dkms.spec.tmp rhel/openvswitch-dkms.spec; fi (printf '\043 Generated automatically -- do not modify! -*- buffer-read-only: t -*-\n' && sed -e 's,[@]VERSION[@],2.10.90,g') < ./rhel/kmod-openvswitch-rhel6.spec.in > kmod-openvswitch-rhel6.spec.tmp || exit 1; if cmp -s kmod-openvswitch-rhel6.spec.tmp rhel/kmod-openvswitch-rhel6.spec; then touch rhel/kmod-openvswitch-rhel6.spec; rm kmod-openvswitch-rhel6.spec.tmp; else mv kmod-openvswitch-rhel6.spec.tmp rhel/kmod-openvswitch-rhel6.spec; fi (printf '\043 Generated automatically -- do not modify! -*- buffer-read-only: t -*-\n' && sed -e 's,[@]VERSION[@],2.10.90,g') < ./rhel/openvswitch-kmod-fedora.spec.in > openvswitch-kmod-fedora.spec.tmp || exit 1; if cmp -s openvswitch-kmod-fedora.spec.tmp rhel/openvswitch-kmod-fedora.spec; then touch rhel/openvswitch-kmod-fedora.spec; rm openvswitch-kmod-fedora.spec.tmp; else mv openvswitch-kmod-fedora.spec.tmp rhel/openvswitch-kmod-fedora.spec; fi (printf '\043 Generated automatically -- do not modify! -*- buffer-read-only: t -*-\n' && sed -e 's,[@]VERSION[@],2.10.90,g') < ./rhel/openvswitch.spec.in > openvswitch.spec.tmp || exit 1; if cmp -s openvswitch.spec.tmp rhel/openvswitch.spec; then touch rhel/openvswitch.spec; rm openvswitch.spec.tmp; else mv openvswitch.spec.tmp rhel/openvswitch.spec; fi (printf '\043 Generated automatically -- do not modify! -*- buffer-read-only: t -*-\n' && sed -e 's,[@]VERSION[@],2.10.90,g') < ./rhel/openvswitch-fedora.spec.in > openvswitch-fedora.spec.tmp || exit 1; if cmp -s openvswitch-fedora.spec.tmp rhel/openvswitch-fedora.spec; then touch rhel/openvswitch-fedora.spec; rm openvswitch-fedora.spec.tmp; else mv openvswitch-fedora.spec.tmp rhel/openvswitch-fedora.spec; fi (printf '\043 Generated automatically -- do not modify! -*- buffer-read-only: t -*-\n' && sed -e 's,[@]VERSION[@],2.10.90,g') \ < ./xenserver/openvswitch-xen.spec.in > openvswitch-xen.spec.tmp || exit 1; \ if cmp -s openvswitch-xen.spec.tmp xenserver/openvswitch-xen.spec; then touch xenserver/openvswitch-xen.spec; rm openvswitch-xen.spec.tmp; else mv openvswitch-xen.spec.tmp xenserver/openvswitch-xen.spec; fi make[3]: Entering directory `/var/lib/jenkins/jobs/upstream_build_from_pw/workspace/datapath' make[3]: Leaving directory `/var/lib/jenkins/jobs/upstream_build_from_pw/workspace/datapath' lib/rtnetlink.c See above for files that use tabs for indentation. Please use spaces instead. make[2]: *** [check-tabs] Error 1 make[2]: Leaving directory `/var/lib/jenkins/jobs/upstream_build_from_pw/workspace' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/var/lib/jenkins/jobs/upstream_build_from_pw/workspace' make: *** [all] Error 2 Please check this out. If you feel there has been an error, please email aconole@bytheb.org Thanks, 0-day Robot
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 9bf2185..2cfe5c8 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -65,6 +65,7 @@ #include "timeval.h" #include "uuid.h" #include "unixctl.h" +#include "rtnetlink.h" enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM}; @@ -1015,6 +1016,8 @@ dpdk_eth_dev_init(struct netdev_dpdk *dev) rte_eth_dev_info_get(dev->port_id, &info); + rtnetlink_blacklist_add(dev->up.name); + if (strstr(info.driver_name, "vf") != NULL) { VLOG_INFO("Virtual function detected, HW_CRC_STRIP will be enabled"); dev->hw_ol_features |= NETDEV_RX_HW_CRC_STRIP; diff --git a/lib/netlink-notifier.c b/lib/netlink-notifier.c index dfecb97..430412d 100644 --- a/lib/netlink-notifier.c +++ b/lib/netlink-notifier.c @@ -27,6 +27,7 @@ #include "netlink-socket.h" #include "openvswitch/ofpbuf.h" #include "openvswitch/vlog.h" +#include "rtnetlink.h" VLOG_DEFINE_THIS_MODULE(netlink_notifier); @@ -234,7 +235,9 @@ nln_report(const struct nln *nln, void *change, int group) LIST_FOR_EACH (notifier, node, &nln->all_notifiers) { if (!change || group == notifier->multicast_group) { - notifier->cb(change, notifier->aux); + if (!rtnetlink_is_in_blacklist(change)) { + notifier->cb(change, notifier->aux); + } } } } diff --git a/lib/rtnetlink.c b/lib/rtnetlink.c index f822dff..c2e12e9 100644 --- a/lib/rtnetlink.c +++ b/lib/rtnetlink.c @@ -26,6 +26,20 @@ #include "netlink-notifier.h" #include "openvswitch/ofpbuf.h" #include "packets.h" +#include "rtnetlink.h" +#include "cmap.h" + +struct if_entry{ + char *name; + struct cmap_node cmap_node; +}; + +static struct cmap if_blacklist; + +static int +rtnetlink_blacklist_init(void); +static int +rtnetlink_blacklist_uninit(void); #if IFLA_INFO_MAX < 5 #define IFLA_INFO_SLAVE_KIND 4 @@ -193,6 +207,8 @@ rtnetlink_notifier_create(rtnetlink_notify_func *cb, void *aux) nln = nln_create(NETLINK_ROUTE, rtnetlink_parse_cb, &rtn_change); } + rtnetlink_blacklist_init(); + return nln_notifier_create(nln, RTNLGRP_LINK, (nln_notify_func *) cb, aux); } @@ -201,6 +217,8 @@ rtnetlink_notifier_create(rtnetlink_notify_func *cb, void *aux) void rtnetlink_notifier_destroy(struct nln_notifier *notifier) { + rtnetlink_blacklist_uninit(); + nln_notifier_destroy(notifier); } @@ -232,3 +250,94 @@ rtnetlink_report_link(void) nln_report(nln, NULL, RTNLGRP_LINK); } } + +static int +rtnetlink_blacklist_init(void) +{ + cmap_init(&if_blacklist); + + return 0; +} + +static int +rtnetlink_blacklist_uninit(void) +{ + struct if_entry *entry; + + CMAP_FOR_EACH(entry, cmap_node, &if_blacklist) { + if(entry) { + free(entry->name); + free(entry); + } + } + + cmap_destroy(&if_blacklist); + return 0; +} + +int +rtnetlink_blacklist_add(const char* name) +{ + struct if_entry *entry; + + CMAP_FOR_EACH_WITH_HASH (entry, cmap_node, hash_string(name, 0), + &if_blacklist) { + if (!strncmp(name, entry->name, sizeof(*name))) { + return 0; + } + } + + entry = xmalloc(sizeof *entry); + entry->name = strdup(name); + cmap_insert(&if_blacklist, &entry->cmap_node, + hash_string(entry->name, 0)); + return 0; +} + +static void +free_if_entry(struct if_entry *entry) +{ + free(entry->name); + free(entry); +} + +int +rtnetlink_blacklist_del(const char* name) +{ + struct if_entry *entry; + + CMAP_FOR_EACH_WITH_HASH (entry, cmap_node, hash_string(name, 0), + &if_blacklist) { + if (!strncmp(name, entry->name, sizeof(*name))) { + break; + } + } + + cmap_remove(&if_blacklist, &entry->cmap_node, + hash_string(name, 0)); + ovsrcu_postpone(free_if_entry, entry); + + return 0; +} + +bool +rtnetlink_is_in_blacklist(void *c) +{ + struct rtnetlink_change *change = c; + struct if_entry *entry; + + if (!change) { + return false; + } + + CMAP_FOR_EACH(entry, cmap_node, &if_blacklist) { + if(entry) { + if (!strncmp(entry->name, change->ifname, sizeof(*change->ifname))) { + return true; + } + } + } + + return false; +} + diff --git a/lib/rtnetlink.h b/lib/rtnetlink.h index 422d1db..0fe7c5b 100755 --- a/lib/rtnetlink.h +++ b/lib/rtnetlink.h @@ -72,4 +72,26 @@ void rtnetlink_notifier_destroy(struct nln_notifier *); void rtnetlink_run(void); void rtnetlink_wait(void); void rtnetlink_report_link(void); + +/** + * rtnetlink_blacklist_add - add if name to blacklist + * @name if name + */ +int +rtnetlink_blacklist_add(const char* name); + +/** + * rtnetlink_blacklist_del - del if name in blacklist + * @name if name + */ +int +rtnetlink_blacklist_del(const char* name); + +/** + * rtnetlink_is_in_blacklist - check if name whether in blacklist + * @c pointer to struct rtnetlink_change + */ +bool +rtnetlink_is_in_blacklist(void *c); + #endif /* rtnetlink.h */
in dpdk ovs mode some ether not need rtnetlink notifier so we can use blacklist remove ethernet from rtnetlink notifier Change-Id: I34121a4c44bfb2fcfe8799130762474bbfe5c015 Signed-off-by: Haifeng Lin <haifeng.lin@huawei.com> --- lib/netdev-dpdk.c | 3 ++ lib/netlink-notifier.c | 5 ++- lib/rtnetlink.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/rtnetlink.h | 22 ++++++++++ 4 files changed, 138 insertions(+), 1 deletion(-)