Skip to content

Commit 15f4323

Browse files
committed
[nexthop] clang-format nexthop-related files
Signed-off-by: Christoph Paasch <[email protected]>
1 parent b4a6d1e commit 15f4323

File tree

6 files changed

+75
-89
lines changed

6 files changed

+75
-89
lines changed

include/netlink/route/nexthop.h

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,53 +22,44 @@ enum {
2222
/* > 0 reserved for nexthop index */
2323
};
2424

25-
extern struct rtnl_nexthop * rtnl_route_nh_alloc(void);
26-
extern struct rtnl_nexthop * rtnl_route_nh_clone(struct rtnl_nexthop *);
27-
extern void rtnl_route_nh_free(struct rtnl_nexthop *);
25+
extern struct rtnl_nexthop *rtnl_route_nh_alloc(void);
26+
extern struct rtnl_nexthop *rtnl_route_nh_clone(struct rtnl_nexthop *);
27+
extern void rtnl_route_nh_free(struct rtnl_nexthop *);
2828

29-
extern int rtnl_route_nh_compare(struct rtnl_nexthop *,
30-
struct rtnl_nexthop *,
31-
uint32_t, int);
29+
extern int rtnl_route_nh_compare(struct rtnl_nexthop *, struct rtnl_nexthop *,
30+
uint32_t, int);
3231

33-
extern int rtnl_route_nh_identical(struct rtnl_nexthop *,
34-
struct rtnl_nexthop *);
32+
extern int rtnl_route_nh_identical(struct rtnl_nexthop *,
33+
struct rtnl_nexthop *);
3534

36-
extern void rtnl_route_nh_dump(struct rtnl_nexthop *,
37-
struct nl_dump_params *);
35+
extern void rtnl_route_nh_dump(struct rtnl_nexthop *, struct nl_dump_params *);
3836

39-
extern void rtnl_route_nh_set_weight(struct rtnl_nexthop *, uint8_t);
40-
extern uint8_t rtnl_route_nh_get_weight(struct rtnl_nexthop *);
41-
extern void rtnl_route_nh_set_ifindex(struct rtnl_nexthop *, int);
42-
extern int rtnl_route_nh_get_ifindex(struct rtnl_nexthop *);
43-
extern void rtnl_route_nh_set_gateway(struct rtnl_nexthop *,
44-
struct nl_addr *);
45-
extern struct nl_addr * rtnl_route_nh_get_gateway(struct rtnl_nexthop *);
46-
extern void rtnl_route_nh_set_flags(struct rtnl_nexthop *,
47-
unsigned int);
48-
extern void rtnl_route_nh_unset_flags(struct rtnl_nexthop *,
49-
unsigned int);
50-
extern unsigned int rtnl_route_nh_get_flags(struct rtnl_nexthop *);
51-
extern void rtnl_route_nh_set_realms(struct rtnl_nexthop *,
52-
uint32_t);
53-
extern uint32_t rtnl_route_nh_get_realms(struct rtnl_nexthop *);
37+
extern void rtnl_route_nh_set_weight(struct rtnl_nexthop *, uint8_t);
38+
extern uint8_t rtnl_route_nh_get_weight(struct rtnl_nexthop *);
39+
extern void rtnl_route_nh_set_ifindex(struct rtnl_nexthop *, int);
40+
extern int rtnl_route_nh_get_ifindex(struct rtnl_nexthop *);
41+
extern void rtnl_route_nh_set_gateway(struct rtnl_nexthop *, struct nl_addr *);
42+
extern struct nl_addr *rtnl_route_nh_get_gateway(struct rtnl_nexthop *);
43+
extern void rtnl_route_nh_set_flags(struct rtnl_nexthop *, unsigned int);
44+
extern void rtnl_route_nh_unset_flags(struct rtnl_nexthop *, unsigned int);
45+
extern unsigned int rtnl_route_nh_get_flags(struct rtnl_nexthop *);
46+
extern void rtnl_route_nh_set_realms(struct rtnl_nexthop *, uint32_t);
47+
extern uint32_t rtnl_route_nh_get_realms(struct rtnl_nexthop *);
5448

55-
extern int rtnl_route_nh_set_newdst(struct rtnl_nexthop *,
56-
struct nl_addr *);
57-
extern struct nl_addr * rtnl_route_nh_get_newdst(struct rtnl_nexthop *);
58-
extern int rtnl_route_nh_set_via(struct rtnl_nexthop *,
59-
struct nl_addr *);
60-
extern struct nl_addr * rtnl_route_nh_get_via(struct rtnl_nexthop *);
61-
extern char * rtnl_route_nh_flags2str(int, char *, size_t);
62-
extern int rtnl_route_nh_str2flags(const char *);
49+
extern int rtnl_route_nh_set_newdst(struct rtnl_nexthop *, struct nl_addr *);
50+
extern struct nl_addr *rtnl_route_nh_get_newdst(struct rtnl_nexthop *);
51+
extern int rtnl_route_nh_set_via(struct rtnl_nexthop *, struct nl_addr *);
52+
extern struct nl_addr *rtnl_route_nh_get_via(struct rtnl_nexthop *);
53+
extern char *rtnl_route_nh_flags2str(int, char *, size_t);
54+
extern int rtnl_route_nh_str2flags(const char *);
6355

6456
/*
6557
* nexthop encapsulations
6658
*/
67-
extern int rtnl_route_nh_encap_mpls(struct rtnl_nexthop *nh,
68-
struct nl_addr *addr,
69-
uint8_t ttl);
70-
extern struct nl_addr * rtnl_route_nh_get_encap_mpls_dst(struct rtnl_nexthop *);
71-
extern uint8_t rtnl_route_nh_get_encap_mpls_ttl(struct rtnl_nexthop *);
59+
extern int rtnl_route_nh_encap_mpls(struct rtnl_nexthop *nh,
60+
struct nl_addr *addr, uint8_t ttl);
61+
extern struct nl_addr *rtnl_route_nh_get_encap_mpls_dst(struct rtnl_nexthop *);
62+
extern uint8_t rtnl_route_nh_get_encap_mpls_ttl(struct rtnl_nexthop *);
7263
#ifdef __cplusplus
7364
}
7465
#endif

lib/route/nexthop-encap.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#ifndef NETLINK_NEXTHOP_ENCAP_H_
2-
#define NETLINK_NEXTHOP_ENCAP_H_
2+
#define NETLINK_NEXTHOP_ENCAP_H_
33

44
struct nh_encap_ops {
55
uint16_t encap_type;
66

7-
int (*build_msg)(struct nl_msg *msg, void *priv);
8-
int (*parse_msg)(struct nlattr *nla, struct rtnl_nexthop *rtnh);
7+
int (*build_msg)(struct nl_msg *msg, void *priv);
8+
int (*parse_msg)(struct nlattr *nla, struct rtnl_nexthop *rtnh);
99

10-
int (*compare)(void *a, void *b);
10+
int (*compare)(void *a, void *b);
1111

12-
void (*dump)(void *priv, struct nl_dump_params *dp);
13-
void (*destructor)(void *priv);
12+
void (*dump)(void *priv, struct nl_dump_params *dp);
13+
void (*destructor)(void *priv);
1414
};
1515

1616
struct rtnl_nh_encap;

lib/route/nexthop.c

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
#include "nl-priv-dynamic-core/nl-core.h"
2222

2323
/** @cond SKIP */
24-
#define NH_ATTR_FLAGS 0x000001
25-
#define NH_ATTR_WEIGHT 0x000002
24+
#define NH_ATTR_FLAGS 0x000001
25+
#define NH_ATTR_WEIGHT 0x000002
2626
#define NH_ATTR_IFINDEX 0x000004
2727
#define NH_ATTR_GATEWAY 0x000008
28-
#define NH_ATTR_REALMS 0x000010
29-
#define NH_ATTR_NEWDST 0x000020
30-
#define NH_ATTR_VIA 0x000040
31-
#define NH_ATTR_ENCAP 0x000080
28+
#define NH_ATTR_REALMS 0x000010
29+
#define NH_ATTR_NEWDST 0x000020
30+
#define NH_ATTR_VIA 0x000040
31+
#define NH_ATTR_ENCAP 0x000080
3232
/** @endcond */
3333

3434
/**
@@ -149,8 +149,9 @@ int rtnl_route_nh_identical(struct rtnl_nexthop *a, struct rtnl_nexthop *b)
149149
{
150150
return !rtnl_route_nh_compare(a, b,
151151
NH_ATTR_IFINDEX | NH_ATTR_REALMS |
152-
NH_ATTR_GATEWAY | NH_ATTR_NEWDST |
153-
NH_ATTR_VIA | NH_ATTR_ENCAP, 0);
152+
NH_ATTR_GATEWAY | NH_ATTR_NEWDST |
153+
NH_ATTR_VIA | NH_ATTR_ENCAP,
154+
0);
154155
}
155156

156157
static void nh_dump_line(struct rtnl_nexthop *nh, struct nl_dump_params *dp)
@@ -170,18 +171,16 @@ static void nh_dump_line(struct rtnl_nexthop *nh, struct nl_dump_params *dp)
170171
nl_dump(dp, "via");
171172

172173
if (nh->ce_mask & NH_ATTR_VIA)
173-
nl_dump(dp, " %s",
174-
nl_addr2str(nh->rtnh_via, buf, sizeof(buf)));
174+
nl_dump(dp, " %s", nl_addr2str(nh->rtnh_via, buf, sizeof(buf)));
175175

176176
if (nh->ce_mask & NH_ATTR_GATEWAY)
177-
nl_dump(dp, " %s", nl_addr2str(nh->rtnh_gateway,
178-
buf, sizeof(buf)));
177+
nl_dump(dp, " %s",
178+
nl_addr2str(nh->rtnh_gateway, buf, sizeof(buf)));
179179

180-
if(nh->ce_mask & NH_ATTR_IFINDEX) {
180+
if (nh->ce_mask & NH_ATTR_IFINDEX) {
181181
if (link_cache) {
182182
nl_dump(dp, " dev %s",
183-
rtnl_link_i2name(link_cache,
184-
nh->rtnh_ifindex,
183+
rtnl_link_i2name(link_cache, nh->rtnh_ifindex,
185184
buf, sizeof(buf)));
186185
} else
187186
nl_dump(dp, " dev %d", nh->rtnh_ifindex);
@@ -214,14 +213,13 @@ static void nh_dump_details(struct rtnl_nexthop *nh, struct nl_dump_params *dp)
214213
nl_addr2str(nh->rtnh_via, buf, sizeof(buf)));
215214

216215
if (nh->ce_mask & NH_ATTR_GATEWAY)
217-
nl_dump(dp, " via %s", nl_addr2str(nh->rtnh_gateway,
218-
buf, sizeof(buf)));
216+
nl_dump(dp, " via %s",
217+
nl_addr2str(nh->rtnh_gateway, buf, sizeof(buf)));
219218

220-
if(nh->ce_mask & NH_ATTR_IFINDEX) {
219+
if (nh->ce_mask & NH_ATTR_IFINDEX) {
221220
if (link_cache) {
222221
nl_dump(dp, " dev %s",
223-
rtnl_link_i2name(link_cache,
224-
nh->rtnh_ifindex,
222+
rtnl_link_i2name(link_cache, nh->rtnh_ifindex,
225223
buf, sizeof(buf)));
226224
} else
227225
nl_dump(dp, " dev %d", nh->rtnh_ifindex);
@@ -236,8 +234,9 @@ static void nh_dump_details(struct rtnl_nexthop *nh, struct nl_dump_params *dp)
236234
RTNL_REALM_TO(nh->rtnh_realms));
237235

238236
if (nh->ce_mask & NH_ATTR_FLAGS)
239-
nl_dump(dp, " <%s>", rtnl_route_nh_flags2str(nh->rtnh_flags,
240-
buf, sizeof(buf)));
237+
nl_dump(dp, " <%s>",
238+
rtnl_route_nh_flags2str(nh->rtnh_flags, buf,
239+
sizeof(buf)));
241240

242241
if (link_cache)
243242
nl_cache_put(link_cache);
@@ -304,7 +303,7 @@ void rtnl_route_nh_set_ifindex(struct rtnl_nexthop *nh, int ifindex)
304303
int rtnl_route_nh_get_ifindex(struct rtnl_nexthop *nh)
305304
{
306305
return nh->rtnh_ifindex;
307-
}
306+
}
308307

309308
/* FIXME: Convert to return an int */
310309
void rtnl_route_nh_set_gateway(struct rtnl_nexthop *nh, struct nl_addr *addr)
@@ -390,7 +389,7 @@ int rtnl_route_nh_set_via(struct rtnl_nexthop *nh, struct nl_addr *addr)
390389
nh->ce_mask |= NH_ATTR_VIA;
391390
} else {
392391
nh->ce_mask &= ~NH_ATTR_VIA;
393-
nh->rtnh_via= NULL;
392+
nh->rtnh_via = NULL;
394393
}
395394

396395
if (old)

lib/route/nexthop_encap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ static struct lwtunnel_encap_type {
1313
} lwtunnel_encap_types[__LWTUNNEL_ENCAP_MAX] = {
1414
[LWTUNNEL_ENCAP_NONE] = { .name = "none" },
1515
[LWTUNNEL_ENCAP_MPLS] = { .name = "mpls", .ops = &mpls_encap_ops },
16-
[LWTUNNEL_ENCAP_IP] = { .name = "ip" },
17-
[LWTUNNEL_ENCAP_IP6] = { .name = "ip6" },
18-
[LWTUNNEL_ENCAP_ILA] = { .name = "ila" },
19-
[LWTUNNEL_ENCAP_BPF] = { .name = "bpf" },
16+
[LWTUNNEL_ENCAP_IP] = { .name = "ip" },
17+
[LWTUNNEL_ENCAP_IP6] = { .name = "ip6" },
18+
[LWTUNNEL_ENCAP_ILA] = { .name = "ila" },
19+
[LWTUNNEL_ENCAP_BPF] = { .name = "bpf" },
2020
};
2121

2222
static const char *nh_encap_type2str(unsigned int type)

lib/route/nh_encap_mpls.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ static void mpls_encap_destructor(void *priv)
4848
}
4949

5050
static struct nla_policy mpls_encap_policy[MPLS_IPTUNNEL_MAX + 1] = {
51-
[MPLS_IPTUNNEL_DST] = { .type = NLA_U32 },
52-
[MPLS_IPTUNNEL_TTL] = { .type = NLA_U8 },
51+
[MPLS_IPTUNNEL_DST] = { .type = NLA_U32 },
52+
[MPLS_IPTUNNEL_TTL] = { .type = NLA_U8 },
5353
};
5454

5555
static int mpls_encap_parse_msg(struct nlattr *nla, struct rtnl_nexthop *nh)
@@ -93,16 +93,15 @@ static int mpls_encap_compare(void *_a, void *_b)
9393
}
9494

9595
struct nh_encap_ops mpls_encap_ops = {
96-
.encap_type = LWTUNNEL_ENCAP_MPLS,
97-
.build_msg = mpls_encap_build_msg,
98-
.parse_msg = mpls_encap_parse_msg,
99-
.compare = mpls_encap_compare,
100-
.dump = mpls_encap_dump,
101-
.destructor = mpls_encap_destructor,
96+
.encap_type = LWTUNNEL_ENCAP_MPLS,
97+
.build_msg = mpls_encap_build_msg,
98+
.parse_msg = mpls_encap_parse_msg,
99+
.compare = mpls_encap_compare,
100+
.dump = mpls_encap_dump,
101+
.destructor = mpls_encap_destructor,
102102
};
103103

104-
int rtnl_route_nh_encap_mpls(struct rtnl_nexthop *nh,
105-
struct nl_addr *addr,
104+
int rtnl_route_nh_encap_mpls(struct rtnl_nexthop *nh, struct nl_addr *addr,
106105
uint8_t ttl)
107106
{
108107
struct mpls_iptunnel_encap *mpls_encap;
@@ -136,7 +135,8 @@ struct nl_addr *rtnl_route_nh_get_encap_mpls_dst(struct rtnl_nexthop *nh)
136135
{
137136
struct mpls_iptunnel_encap *mpls_encap;
138137

139-
if (!nh->rtnh_encap || nh->rtnh_encap->ops->encap_type != LWTUNNEL_ENCAP_MPLS)
138+
if (!nh->rtnh_encap ||
139+
nh->rtnh_encap->ops->encap_type != LWTUNNEL_ENCAP_MPLS)
140140
return NULL;
141141

142142
mpls_encap = (struct mpls_iptunnel_encap *)nh->rtnh_encap->priv;
@@ -150,7 +150,8 @@ uint8_t rtnl_route_nh_get_encap_mpls_ttl(struct rtnl_nexthop *nh)
150150
{
151151
struct mpls_iptunnel_encap *mpls_encap;
152152

153-
if (!nh->rtnh_encap || nh->rtnh_encap->ops->encap_type != LWTUNNEL_ENCAP_MPLS)
153+
if (!nh->rtnh_encap ||
154+
nh->rtnh_encap->ops->encap_type != LWTUNNEL_ENCAP_MPLS)
154155
return 0;
155156

156157
mpls_encap = (struct mpls_iptunnel_encap *)nh->rtnh_encap->priv;

tools/clang-format.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ EXCLUDE_PATHS_TOPLEVEL+=(
103103
"include/netlink/route/neighbour.h"
104104
"include/netlink/route/neightbl.h"
105105
"include/netlink/route/netconf.h"
106-
"include/netlink/route/nexthop.h"
107106
"include/netlink/route/pktloc.h"
108107
"include/netlink/route/qdisc.h"
109108
"include/netlink/route/qdisc/cbq.h"
@@ -239,10 +238,6 @@ EXCLUDE_PATHS_TOPLEVEL+=(
239238
"lib/route/mdb.c"
240239
"lib/route/neigh.c"
241240
"lib/route/netconf.c"
242-
"lib/route/nexthop-encap.h"
243-
"lib/route/nexthop.c"
244-
"lib/route/nexthop_encap.c"
245-
"lib/route/nh_encap_mpls.c"
246241
"lib/route/pktloc.c"
247242
"lib/route/qdisc.c"
248243
"lib/route/qdisc/blackhole.c"

0 commit comments

Comments
 (0)