|
|
4aca6e |
From 86b1bf040e1282bf95244c9c8b43c16567b6e133 Mon Sep 17 00:00:00 2001
|
|
|
4aca6e |
From: Phil Sutter <psutter@redhat.com>
|
|
|
4aca6e |
Date: Tue, 28 Feb 2017 16:12:38 +0100
|
|
|
4aca6e |
Subject: [PATCH] bridge: code cleanup
|
|
|
4aca6e |
|
|
|
4aca6e |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1417289
|
|
|
4aca6e |
Upstream Status: iproute2.git commit df4b043f0845e
|
|
|
4aca6e |
|
|
|
4aca6e |
commit df4b043f0845eaf3534b32925c5e79970f9a95a0
|
|
|
4aca6e |
Author: Stephen Hemminger <stephen@networkplumber.org>
|
|
|
4aca6e |
Date: Mon Mar 21 11:56:01 2016 -0700
|
|
|
4aca6e |
|
|
|
4aca6e |
bridge: code cleanup
|
|
|
4aca6e |
|
|
|
4aca6e |
Use checkpatch auto fix to cleanup lingering style issues
|
|
|
4aca6e |
---
|
|
|
4aca6e |
bridge/fdb.c | 20 +++++++++++---------
|
|
|
4aca6e |
bridge/link.c | 25 +++++++++++++------------
|
|
|
4aca6e |
bridge/mdb.c | 6 +++---
|
|
|
4aca6e |
bridge/monitor.c | 13 +++++++------
|
|
|
4aca6e |
bridge/vlan.c | 9 +++++----
|
|
|
4aca6e |
5 files changed, 39 insertions(+), 34 deletions(-)
|
|
|
4aca6e |
|
|
|
4aca6e |
diff --git a/bridge/fdb.c b/bridge/fdb.c
|
|
|
4aca6e |
index 0222fd6..2d2498a 100644
|
|
|
4aca6e |
--- a/bridge/fdb.c
|
|
|
4aca6e |
+++ b/bridge/fdb.c
|
|
|
4aca6e |
@@ -33,12 +33,12 @@ static void usage(void)
|
|
|
4aca6e |
fprintf(stderr, "Usage: bridge fdb { add | append | del | replace } ADDR dev DEV\n"
|
|
|
4aca6e |
" [ self ] [ master ] [ use ] [ router ]\n"
|
|
|
4aca6e |
" [ local | static | dynamic ] [ dst IPADDR ] [ vlan VID ]\n"
|
|
|
4aca6e |
- " [ port PORT] [ vni VNI ] [ via DEV ]\n");
|
|
|
4aca6e |
+ " [ port PORT] [ vni VNI ] [ via DEV ]\n");
|
|
|
4aca6e |
fprintf(stderr, " bridge fdb [ show [ br BRDEV ] [ brport DEV ] ]\n");
|
|
|
4aca6e |
exit(-1);
|
|
|
4aca6e |
}
|
|
|
4aca6e |
|
|
|
4aca6e |
-static const char *state_n2a(unsigned s)
|
|
|
4aca6e |
+static const char *state_n2a(unsigned int s)
|
|
|
4aca6e |
{
|
|
|
4aca6e |
static char buf[32];
|
|
|
4aca6e |
|
|
|
4aca6e |
@@ -63,7 +63,7 @@ int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
|
|
4aca6e |
FILE *fp = arg;
|
|
|
4aca6e |
struct ndmsg *r = NLMSG_DATA(n);
|
|
|
4aca6e |
int len = n->nlmsg_len;
|
|
|
4aca6e |
- struct rtattr * tb[NDA_MAX+1];
|
|
|
4aca6e |
+ struct rtattr *tb[NDA_MAX+1];
|
|
|
4aca6e |
|
|
|
4aca6e |
if (n->nlmsg_type != RTM_NEWNEIGH && n->nlmsg_type != RTM_DELNEIGH) {
|
|
|
4aca6e |
fprintf(stderr, "Not RTM_NEWNEIGH: %08x %08x %08x\n",
|
|
|
4aca6e |
@@ -118,6 +118,7 @@ int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
|
|
4aca6e |
|
|
|
4aca6e |
if (tb[NDA_VLAN]) {
|
|
|
4aca6e |
__u16 vid = rta_getattr_u16(tb[NDA_VLAN]);
|
|
|
4aca6e |
+
|
|
|
4aca6e |
fprintf(fp, "vlan %hu ", vid);
|
|
|
4aca6e |
}
|
|
|
4aca6e |
|
|
|
4aca6e |
@@ -170,9 +171,9 @@ int print_fdb(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
|
|
4aca6e |
static int fdb_show(int argc, char **argv)
|
|
|
4aca6e |
{
|
|
|
4aca6e |
struct {
|
|
|
4aca6e |
- struct nlmsghdr n;
|
|
|
4aca6e |
+ struct nlmsghdr n;
|
|
|
4aca6e |
struct ifinfomsg ifm;
|
|
|
4aca6e |
- char buf[256];
|
|
|
4aca6e |
+ char buf[256];
|
|
|
4aca6e |
} req;
|
|
|
4aca6e |
|
|
|
4aca6e |
char *filter_dev = NULL;
|
|
|
4aca6e |
@@ -199,6 +200,7 @@ static int fdb_show(int argc, char **argv)
|
|
|
4aca6e |
|
|
|
4aca6e |
if (br) {
|
|
|
4aca6e |
int br_ifindex = ll_name_to_index(br);
|
|
|
4aca6e |
+
|
|
|
4aca6e |
if (br_ifindex == 0) {
|
|
|
4aca6e |
fprintf(stderr, "Cannot find bridge device \"%s\"\n", br);
|
|
|
4aca6e |
return -1;
|
|
|
4aca6e |
@@ -234,9 +236,9 @@ static int fdb_show(int argc, char **argv)
|
|
|
4aca6e |
static int fdb_modify(int cmd, int flags, int argc, char **argv)
|
|
|
4aca6e |
{
|
|
|
4aca6e |
struct {
|
|
|
4aca6e |
- struct nlmsghdr n;
|
|
|
4aca6e |
- struct ndmsg ndm;
|
|
|
4aca6e |
- char buf[256];
|
|
|
4aca6e |
+ struct nlmsghdr n;
|
|
|
4aca6e |
+ struct ndmsg ndm;
|
|
|
4aca6e |
+ char buf[256];
|
|
|
4aca6e |
} req;
|
|
|
4aca6e |
char *addr = NULL;
|
|
|
4aca6e |
char *d = NULL;
|
|
|
4aca6e |
@@ -297,7 +299,7 @@ static int fdb_modify(int cmd, int flags, int argc, char **argv)
|
|
|
4aca6e |
req.ndm.ndm_flags |= NTF_MASTER;
|
|
|
4aca6e |
} else if (matches(*argv, "router") == 0) {
|
|
|
4aca6e |
req.ndm.ndm_flags |= NTF_ROUTER;
|
|
|
4aca6e |
- } else if (matches(*argv, "local") == 0||
|
|
|
4aca6e |
+ } else if (matches(*argv, "local") == 0 ||
|
|
|
4aca6e |
matches(*argv, "permanent") == 0) {
|
|
|
4aca6e |
req.ndm.ndm_state |= NUD_PERMANENT;
|
|
|
4aca6e |
} else if (matches(*argv, "temp") == 0 ||
|
|
|
4aca6e |
diff --git a/bridge/link.c b/bridge/link.c
|
|
|
4aca6e |
index a9b1262..353e1c3 100644
|
|
|
4aca6e |
--- a/bridge/link.c
|
|
|
4aca6e |
+++ b/bridge/link.c
|
|
|
4aca6e |
@@ -25,17 +25,17 @@ static const char *port_states[] = {
|
|
|
4aca6e |
[BR_STATE_BLOCKING] = "blocking",
|
|
|
4aca6e |
};
|
|
|
4aca6e |
|
|
|
4aca6e |
-extern char *if_indextoname (unsigned int __ifindex, char *__ifname);
|
|
|
4aca6e |
+extern char *if_indextoname(unsigned int __ifindex, char *__ifname);
|
|
|
4aca6e |
|
|
|
4aca6e |
-static void print_link_flags(FILE *fp, unsigned flags)
|
|
|
4aca6e |
+static void print_link_flags(FILE *fp, unsigned int flags)
|
|
|
4aca6e |
{
|
|
|
4aca6e |
fprintf(fp, "<");
|
|
|
4aca6e |
if (flags & IFF_UP && !(flags & IFF_RUNNING))
|
|
|
4aca6e |
fprintf(fp, "NO-CARRIER%s", flags ? "," : "");
|
|
|
4aca6e |
flags &= ~IFF_RUNNING;
|
|
|
4aca6e |
#define _PF(f) if (flags&IFF_##f) { \
|
|
|
4aca6e |
- flags &= ~IFF_##f ; \
|
|
|
4aca6e |
- fprintf(fp, #f "%s", flags ? "," : ""); }
|
|
|
4aca6e |
+ flags &= ~IFF_##f ; \
|
|
|
4aca6e |
+ fprintf(fp, #f "%s", flags ? "," : ""); }
|
|
|
4aca6e |
_PF(LOOPBACK);
|
|
|
4aca6e |
_PF(BROADCAST);
|
|
|
4aca6e |
_PF(POINTOPOINT);
|
|
|
4aca6e |
@@ -55,7 +55,7 @@ static void print_link_flags(FILE *fp, unsigned flags)
|
|
|
4aca6e |
_PF(DORMANT);
|
|
|
4aca6e |
_PF(ECHO);
|
|
|
4aca6e |
#undef _PF
|
|
|
4aca6e |
- if (flags)
|
|
|
4aca6e |
+ if (flags)
|
|
|
4aca6e |
fprintf(fp, "%x", flags);
|
|
|
4aca6e |
fprintf(fp, "> ");
|
|
|
4aca6e |
}
|
|
|
4aca6e |
@@ -69,7 +69,7 @@ static const char *hw_mode[] = {"VEB", "VEPA"};
|
|
|
4aca6e |
|
|
|
4aca6e |
static void print_operstate(FILE *f, __u8 state)
|
|
|
4aca6e |
{
|
|
|
4aca6e |
- if (state >= sizeof(oper_states)/sizeof(oper_states[0]))
|
|
|
4aca6e |
+ if (state >= ARRAY_SIZE(oper_states))
|
|
|
4aca6e |
fprintf(f, "state %#x ", state);
|
|
|
4aca6e |
else
|
|
|
4aca6e |
fprintf(f, "state %s ", oper_states[state]);
|
|
|
4aca6e |
@@ -90,7 +90,7 @@ static void print_onoff(FILE *f, char *flag, __u8 val)
|
|
|
4aca6e |
|
|
|
4aca6e |
static void print_hwmode(FILE *f, __u16 mode)
|
|
|
4aca6e |
{
|
|
|
4aca6e |
- if (mode >= sizeof(hw_mode)/sizeof(hw_mode[0]))
|
|
|
4aca6e |
+ if (mode >= ARRAY_SIZE(hw_mode))
|
|
|
4aca6e |
fprintf(f, "hwmode %#hx ", mode);
|
|
|
4aca6e |
else
|
|
|
4aca6e |
fprintf(f, "hwmode %s ", hw_mode[mode]);
|
|
|
4aca6e |
@@ -102,14 +102,14 @@ int print_linkinfo(const struct sockaddr_nl *who,
|
|
|
4aca6e |
FILE *fp = arg;
|
|
|
4aca6e |
int len = n->nlmsg_len;
|
|
|
4aca6e |
struct ifinfomsg *ifi = NLMSG_DATA(n);
|
|
|
4aca6e |
- struct rtattr * tb[IFLA_MAX+1];
|
|
|
4aca6e |
+ struct rtattr *tb[IFLA_MAX+1];
|
|
|
4aca6e |
char b1[IFNAMSIZ];
|
|
|
4aca6e |
|
|
|
4aca6e |
len -= NLMSG_LENGTH(sizeof(*ifi));
|
|
|
4aca6e |
if (len < 0) {
|
|
|
4aca6e |
fprintf(stderr, "Message too short!\n");
|
|
|
4aca6e |
return -1;
|
|
|
4aca6e |
- }
|
|
|
4aca6e |
+ }
|
|
|
4aca6e |
|
|
|
4aca6e |
if (!(ifi->ifi_family == AF_BRIDGE || ifi->ifi_family == AF_UNSPEC))
|
|
|
4aca6e |
return 0;
|
|
|
4aca6e |
@@ -136,6 +136,7 @@ int print_linkinfo(const struct sockaddr_nl *who,
|
|
|
4aca6e |
if (tb[IFLA_LINK]) {
|
|
|
4aca6e |
SPRINT_BUF(b1);
|
|
|
4aca6e |
int iflink = rta_getattr_u32(tb[IFLA_LINK]);
|
|
|
4aca6e |
+
|
|
|
4aca6e |
if (iflink == 0)
|
|
|
4aca6e |
fprintf(fp, "@NONE: ");
|
|
|
4aca6e |
else
|
|
|
4aca6e |
@@ -220,7 +221,7 @@ static void usage(void)
|
|
|
4aca6e |
{
|
|
|
4aca6e |
fprintf(stderr, "Usage: bridge link set dev DEV [ cost COST ] [ priority PRIO ] [ state STATE ]\n");
|
|
|
4aca6e |
fprintf(stderr, " [ guard {on | off} ]\n");
|
|
|
4aca6e |
- fprintf(stderr, " [ hairpin {on | off} ] \n");
|
|
|
4aca6e |
+ fprintf(stderr, " [ hairpin {on | off} ]\n");
|
|
|
4aca6e |
fprintf(stderr, " [ fastleave {on | off} ]\n");
|
|
|
4aca6e |
fprintf(stderr, " [ root_block {on | off} ]\n");
|
|
|
4aca6e |
fprintf(stderr, " [ learning {on | off} ]\n");
|
|
|
4aca6e |
@@ -319,6 +320,7 @@ static int brlink_modify(int argc, char **argv)
|
|
|
4aca6e |
NEXT_ARG();
|
|
|
4aca6e |
char *endptr;
|
|
|
4aca6e |
size_t nstates = sizeof(port_states) / sizeof(*port_states);
|
|
|
4aca6e |
+
|
|
|
4aca6e |
state = strtol(*argv, &endptr, 10);
|
|
|
4aca6e |
if (!(**argv != '\0' && *endptr == '\0')) {
|
|
|
4aca6e |
for (state = 0; state < nstates; state++)
|
|
|
4aca6e |
@@ -339,8 +341,7 @@ static int brlink_modify(int argc, char **argv)
|
|
|
4aca6e |
mode = BRIDGE_MODE_VEB;
|
|
|
4aca6e |
else {
|
|
|
4aca6e |
fprintf(stderr,
|
|
|
4aca6e |
- "Mode argument must be \"vepa\" or "
|
|
|
4aca6e |
- "\"veb\".\n");
|
|
|
4aca6e |
+ "Mode argument must be \"vepa\" or \"veb\".\n");
|
|
|
4aca6e |
return -1;
|
|
|
4aca6e |
}
|
|
|
4aca6e |
} else if (strcmp(*argv, "self") == 0) {
|
|
|
4aca6e |
diff --git a/bridge/mdb.c b/bridge/mdb.c
|
|
|
4aca6e |
index 97da4dc..842536e 100644
|
|
|
4aca6e |
--- a/bridge/mdb.c
|
|
|
4aca6e |
+++ b/bridge/mdb.c
|
|
|
4aca6e |
@@ -21,7 +21,7 @@
|
|
|
4aca6e |
|
|
|
4aca6e |
#ifndef MDBA_RTA
|
|
|
4aca6e |
#define MDBA_RTA(r) \
|
|
|
4aca6e |
- ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct br_port_msg))))
|
|
|
4aca6e |
+ ((struct rtattr *)(((char *)(r)) + NLMSG_ALIGN(sizeof(struct br_port_msg))))
|
|
|
4aca6e |
#endif
|
|
|
4aca6e |
|
|
|
4aca6e |
static unsigned int filter_index;
|
|
|
4aca6e |
@@ -224,9 +224,9 @@ static int mdb_show(int argc, char **argv)
|
|
|
4aca6e |
static int mdb_modify(int cmd, int flags, int argc, char **argv)
|
|
|
4aca6e |
{
|
|
|
4aca6e |
struct {
|
|
|
4aca6e |
- struct nlmsghdr n;
|
|
|
4aca6e |
+ struct nlmsghdr n;
|
|
|
4aca6e |
struct br_port_msg bpm;
|
|
|
4aca6e |
- char buf[1024];
|
|
|
4aca6e |
+ char buf[1024];
|
|
|
4aca6e |
} req;
|
|
|
4aca6e |
struct br_mdb_entry entry;
|
|
|
4aca6e |
char *d = NULL, *p = NULL, *grp = NULL;
|
|
|
4aca6e |
diff --git a/bridge/monitor.c b/bridge/monitor.c
|
|
|
4aca6e |
index 590de76..987257c 100644
|
|
|
4aca6e |
--- a/bridge/monitor.c
|
|
|
4aca6e |
+++ b/bridge/monitor.c
|
|
|
4aca6e |
@@ -86,10 +86,10 @@ static int accept_msg(const struct sockaddr_nl *who,
|
|
|
4aca6e |
int do_monitor(int argc, char **argv)
|
|
|
4aca6e |
{
|
|
|
4aca6e |
char *file = NULL;
|
|
|
4aca6e |
- unsigned groups = ~RTMGRP_TC;
|
|
|
4aca6e |
- int llink=0;
|
|
|
4aca6e |
- int lneigh=0;
|
|
|
4aca6e |
- int lmdb=0;
|
|
|
4aca6e |
+ unsigned int groups = ~RTMGRP_TC;
|
|
|
4aca6e |
+ int llink = 0;
|
|
|
4aca6e |
+ int lneigh = 0;
|
|
|
4aca6e |
+ int lmdb = 0;
|
|
|
4aca6e |
|
|
|
4aca6e |
rtnl_close(&rth);
|
|
|
4aca6e |
|
|
|
4aca6e |
@@ -98,7 +98,7 @@ int do_monitor(int argc, char **argv)
|
|
|
4aca6e |
NEXT_ARG();
|
|
|
4aca6e |
file = *argv;
|
|
|
4aca6e |
} else if (matches(*argv, "link") == 0) {
|
|
|
4aca6e |
- llink=1;
|
|
|
4aca6e |
+ llink = 1;
|
|
|
4aca6e |
groups = 0;
|
|
|
4aca6e |
} else if (matches(*argv, "fdb") == 0) {
|
|
|
4aca6e |
lneigh = 1;
|
|
|
4aca6e |
@@ -108,7 +108,7 @@ int do_monitor(int argc, char **argv)
|
|
|
4aca6e |
groups = 0;
|
|
|
4aca6e |
} else if (strcmp(*argv, "all") == 0) {
|
|
|
4aca6e |
groups = ~RTMGRP_TC;
|
|
|
4aca6e |
- prefix_banner=1;
|
|
|
4aca6e |
+ prefix_banner = 1;
|
|
|
4aca6e |
} else if (matches(*argv, "help") == 0) {
|
|
|
4aca6e |
usage();
|
|
|
4aca6e |
} else {
|
|
|
4aca6e |
@@ -132,6 +132,7 @@ int do_monitor(int argc, char **argv)
|
|
|
4aca6e |
if (file) {
|
|
|
4aca6e |
FILE *fp;
|
|
|
4aca6e |
int err;
|
|
|
4aca6e |
+
|
|
|
4aca6e |
fp = fopen(file, "r");
|
|
|
4aca6e |
if (fp == NULL) {
|
|
|
4aca6e |
perror("Cannot fopen");
|
|
|
4aca6e |
diff --git a/bridge/vlan.c b/bridge/vlan.c
|
|
|
4aca6e |
index ac2f523..ae58832 100644
|
|
|
4aca6e |
--- a/bridge/vlan.c
|
|
|
4aca6e |
+++ b/bridge/vlan.c
|
|
|
4aca6e |
@@ -26,9 +26,9 @@ static void usage(void)
|
|
|
4aca6e |
static int vlan_modify(int cmd, int argc, char **argv)
|
|
|
4aca6e |
{
|
|
|
4aca6e |
struct {
|
|
|
4aca6e |
- struct nlmsghdr n;
|
|
|
4aca6e |
- struct ifinfomsg ifm;
|
|
|
4aca6e |
- char buf[1024];
|
|
|
4aca6e |
+ struct nlmsghdr n;
|
|
|
4aca6e |
+ struct ifinfomsg ifm;
|
|
|
4aca6e |
+ char buf[1024];
|
|
|
4aca6e |
} req;
|
|
|
4aca6e |
char *d = NULL;
|
|
|
4aca6e |
short vid = -1;
|
|
|
4aca6e |
@@ -51,6 +51,7 @@ static int vlan_modify(int cmd, int argc, char **argv)
|
|
|
4aca6e |
d = *argv;
|
|
|
4aca6e |
} else if (strcmp(*argv, "vid") == 0) {
|
|
|
4aca6e |
char *p;
|
|
|
4aca6e |
+
|
|
|
4aca6e |
NEXT_ARG();
|
|
|
4aca6e |
p = strchr(*argv, '-');
|
|
|
4aca6e |
if (p) {
|
|
|
4aca6e |
@@ -144,7 +145,7 @@ static int print_vlan(const struct sockaddr_nl *who,
|
|
|
4aca6e |
FILE *fp = arg;
|
|
|
4aca6e |
struct ifinfomsg *ifm = NLMSG_DATA(n);
|
|
|
4aca6e |
int len = n->nlmsg_len;
|
|
|
4aca6e |
- struct rtattr * tb[IFLA_MAX+1];
|
|
|
4aca6e |
+ struct rtattr *tb[IFLA_MAX+1];
|
|
|
4aca6e |
|
|
|
4aca6e |
if (n->nlmsg_type != RTM_NEWLINK) {
|
|
|
4aca6e |
fprintf(stderr, "Not RTM_NEWLINK: %08x %08x %08x\n",
|
|
|
4aca6e |
--
|
|
|
4aca6e |
1.8.3.1
|
|
|
4aca6e |
|