Skip to content

Commit cf3266a

Browse files
hao022davem330
authored andcommitted
net: openvswitch: improve the coding style
Not change the logic, just improve the coding style. Cc: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 34e1ec3 commit cf3266a

4 files changed

Lines changed: 55 additions & 41 deletions

File tree

‎net/openvswitch/actions.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,8 @@ static int set_sctp(struct sk_buff *skb, struct sw_flow_key *flow_key,
741741
return 0;
742742
}
743743

744-
static int ovs_vport_output(struct net *net, struct sock *sk, struct sk_buff *skb)
744+
static int ovs_vport_output(struct net *net, struct sock *sk,
745+
struct sk_buff *skb)
745746
{
746747
struct ovs_frag_data *data = this_cpu_ptr(&ovs_frag_data_storage);
747748
struct vport *vport = data->vport;
@@ -920,7 +921,7 @@ static int output_userspace(struct datapath *dp, struct sk_buff *skb,
920921
upcall.mru = OVS_CB(skb)->mru;
921922

922923
for (a = nla_data(attr), rem = nla_len(attr); rem > 0;
923-
a = nla_next(a, &rem)) {
924+
a = nla_next(a, &rem)) {
924925
switch (nla_type(a)) {
925926
case OVS_USERSPACE_ATTR_USERDATA:
926927
upcall.userdata = a;

‎net/openvswitch/datapath.c‎

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ struct vport *ovs_lookup_vport(const struct datapath *dp, u16 port_no)
182182

183183
head = vport_hash_bucket(dp, port_no);
184184
hlist_for_each_entry_rcu(vport, head, dp_hash_node,
185-
lockdep_ovsl_is_held()) {
185+
lockdep_ovsl_is_held()) {
186186
if (vport->port_no == port_no)
187187
return vport;
188188
}
@@ -254,7 +254,7 @@ void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key)
254254
error = ovs_execute_actions(dp, skb, sf_acts, key);
255255
if (unlikely(error))
256256
net_dbg_ratelimited("ovs: action execution error on datapath %s: %d\n",
257-
ovs_dp_name(dp), error);
257+
ovs_dp_name(dp), error);
258258

259259
stats_counter = &stats->n_hit;
260260

@@ -302,7 +302,7 @@ int ovs_dp_upcall(struct datapath *dp, struct sk_buff *skb,
302302
static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb,
303303
const struct sw_flow_key *key,
304304
const struct dp_upcall_info *upcall_info,
305-
uint32_t cutlen)
305+
uint32_t cutlen)
306306
{
307307
unsigned int gso_type = skb_shinfo(skb)->gso_type;
308308
struct sw_flow_key later_key;
@@ -1080,11 +1080,12 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info)
10801080
}
10811081

10821082
/* Factor out action copy to avoid "Wframe-larger-than=1024" warning. */
1083-
static noinline_for_stack struct sw_flow_actions *get_flow_actions(struct net *net,
1084-
const struct nlattr *a,
1085-
const struct sw_flow_key *key,
1086-
const struct sw_flow_mask *mask,
1087-
bool log)
1083+
static noinline_for_stack
1084+
struct sw_flow_actions *get_flow_actions(struct net *net,
1085+
const struct nlattr *a,
1086+
const struct sw_flow_key *key,
1087+
const struct sw_flow_mask *mask,
1088+
bool log)
10881089
{
10891090
struct sw_flow_actions *acts;
10901091
struct sw_flow_key masked_key;
@@ -1383,7 +1384,8 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info)
13831384

13841385
ovs_notify(&dp_flow_genl_family, reply, info);
13851386
} else {
1386-
netlink_set_err(sock_net(skb->sk)->genl_sock, 0, 0, PTR_ERR(reply));
1387+
netlink_set_err(sock_net(skb->sk)->genl_sock, 0, 0,
1388+
PTR_ERR(reply));
13871389
}
13881390
}
13891391

@@ -1513,7 +1515,7 @@ static int ovs_dp_cmd_fill_info(struct datapath *dp, struct sk_buff *skb,
15131515
int err;
15141516

15151517
ovs_header = genlmsg_put(skb, portid, seq, &dp_datapath_genl_family,
1516-
flags, cmd);
1518+
flags, cmd);
15171519
if (!ovs_header)
15181520
goto error;
15191521

@@ -1572,11 +1574,13 @@ static struct datapath *lookup_datapath(struct net *net,
15721574
return dp ? dp : ERR_PTR(-ENODEV);
15731575
}
15741576

1575-
static void ovs_dp_reset_user_features(struct sk_buff *skb, struct genl_info *info)
1577+
static void ovs_dp_reset_user_features(struct sk_buff *skb,
1578+
struct genl_info *info)
15761579
{
15771580
struct datapath *dp;
15781581

1579-
dp = lookup_datapath(sock_net(skb->sk), info->userhdr, info->attrs);
1582+
dp = lookup_datapath(sock_net(skb->sk), info->userhdr,
1583+
info->attrs);
15801584
if (IS_ERR(dp))
15811585
return;
15821586

@@ -2075,7 +2079,7 @@ static unsigned int ovs_get_max_headroom(struct datapath *dp)
20752079

20762080
for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++) {
20772081
hlist_for_each_entry_rcu(vport, &dp->ports[i], dp_hash_node,
2078-
lockdep_ovsl_is_held()) {
2082+
lockdep_ovsl_is_held()) {
20792083
dev = vport->dev;
20802084
dev_headroom = netdev_get_fwd_headroom(dev);
20812085
if (dev_headroom > max_headroom)
@@ -2093,10 +2097,11 @@ static void ovs_update_headroom(struct datapath *dp, unsigned int new_headroom)
20932097
int i;
20942098

20952099
dp->max_headroom = new_headroom;
2096-
for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++)
2100+
for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++) {
20972101
hlist_for_each_entry_rcu(vport, &dp->ports[i], dp_hash_node,
2098-
lockdep_ovsl_is_held())
2102+
lockdep_ovsl_is_held())
20992103
netdev_set_rx_headroom(vport->dev, new_headroom);
2104+
}
21002105
}
21012106

21022107
static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info)
@@ -2551,7 +2556,8 @@ static int __init dp_init(void)
25512556
{
25522557
int err;
25532558

2554-
BUILD_BUG_ON(sizeof(struct ovs_skb_cb) > sizeof_field(struct sk_buff, cb));
2559+
BUILD_BUG_ON(sizeof(struct ovs_skb_cb) >
2560+
sizeof_field(struct sk_buff, cb));
25552561

25562562
pr_info("Open vSwitch switching datapath\n");
25572563

‎net/openvswitch/flow_table.c‎

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,16 @@ static void flow_free(struct sw_flow *flow)
111111
if (ovs_identifier_is_key(&flow->id))
112112
kfree(flow->id.unmasked_key);
113113
if (flow->sf_acts)
114-
ovs_nla_free_flow_actions((struct sw_flow_actions __force *)flow->sf_acts);
114+
ovs_nla_free_flow_actions((struct sw_flow_actions __force *)
115+
flow->sf_acts);
115116
/* We open code this to make sure cpu 0 is always considered */
116-
for (cpu = 0; cpu < nr_cpu_ids; cpu = cpumask_next(cpu, &flow->cpu_used_mask))
117+
for (cpu = 0; cpu < nr_cpu_ids;
118+
cpu = cpumask_next(cpu, &flow->cpu_used_mask)) {
117119
if (flow->stats[cpu])
118120
kmem_cache_free(flow_stats_cache,
119121
(struct sw_flow_stats __force *)flow->stats[cpu]);
122+
}
123+
120124
kmem_cache_free(flow_cache, flow);
121125
}
122126

@@ -192,7 +196,7 @@ static void tbl_mask_array_reset_counters(struct mask_array *ma)
192196
* zero based counter we store the value at reset, and subtract it
193197
* later when processing.
194198
*/
195-
for (i = 0; i < ma->max; i++) {
199+
for (i = 0; i < ma->max; i++) {
196200
ma->masks_usage_zero_cntr[i] = 0;
197201

198202
for_each_possible_cpu(cpu) {
@@ -273,7 +277,7 @@ static int tbl_mask_array_add_mask(struct flow_table *tbl,
273277

274278
if (ma_count >= ma->max) {
275279
err = tbl_mask_array_realloc(tbl, ma->max +
276-
MASK_ARRAY_SIZE_MIN);
280+
MASK_ARRAY_SIZE_MIN);
277281
if (err)
278282
return err;
279283

@@ -288,7 +292,7 @@ static int tbl_mask_array_add_mask(struct flow_table *tbl,
288292
BUG_ON(ovsl_dereference(ma->masks[ma_count]));
289293

290294
rcu_assign_pointer(ma->masks[ma_count], new);
291-
WRITE_ONCE(ma->count, ma_count +1);
295+
WRITE_ONCE(ma->count, ma_count + 1);
292296

293297
return 0;
294298
}
@@ -309,10 +313,10 @@ static void tbl_mask_array_del_mask(struct flow_table *tbl,
309313
return;
310314

311315
found:
312-
WRITE_ONCE(ma->count, ma_count -1);
316+
WRITE_ONCE(ma->count, ma_count - 1);
313317

314-
rcu_assign_pointer(ma->masks[i], ma->masks[ma_count -1]);
315-
RCU_INIT_POINTER(ma->masks[ma_count -1], NULL);
318+
rcu_assign_pointer(ma->masks[i], ma->masks[ma_count - 1]);
319+
RCU_INIT_POINTER(ma->masks[ma_count - 1], NULL);
316320

317321
kfree_rcu(mask, rcu);
318322

@@ -448,16 +452,17 @@ int ovs_flow_tbl_init(struct flow_table *table)
448452

449453
static void flow_tbl_destroy_rcu_cb(struct rcu_head *rcu)
450454
{
451-
struct table_instance *ti = container_of(rcu, struct table_instance, rcu);
455+
struct table_instance *ti;
452456

457+
ti = container_of(rcu, struct table_instance, rcu);
453458
__table_instance_destroy(ti);
454459
}
455460

456461
static void table_instance_flow_free(struct flow_table *table,
457-
struct table_instance *ti,
458-
struct table_instance *ufid_ti,
459-
struct sw_flow *flow,
460-
bool count)
462+
struct table_instance *ti,
463+
struct table_instance *ufid_ti,
464+
struct sw_flow *flow,
465+
bool count)
461466
{
462467
hlist_del_rcu(&flow->flow_table.node[ti->node_ver]);
463468
if (count)
@@ -484,9 +489,9 @@ void table_instance_flow_flush(struct flow_table *table,
484489
return;
485490

486491
for (i = 0; i < ti->n_buckets; i++) {
487-
struct sw_flow *flow;
488492
struct hlist_head *head = &ti->buckets[i];
489493
struct hlist_node *n;
494+
struct sw_flow *flow;
490495

491496
hlist_for_each_entry_safe(flow, n, head,
492497
flow_table.node[ti->node_ver]) {
@@ -661,7 +666,7 @@ static int flow_key_start(const struct sw_flow_key *key)
661666
return 0;
662667
else
663668
return rounddown(offsetof(struct sw_flow_key, phy),
664-
sizeof(long));
669+
sizeof(long));
665670
}
666671

667672
static bool cmp_key(const struct sw_flow_key *key1,
@@ -673,7 +678,7 @@ static bool cmp_key(const struct sw_flow_key *key1,
673678
long diffs = 0;
674679
int i;
675680

676-
for (i = key_start; i < key_end; i += sizeof(long))
681+
for (i = key_start; i < key_end; i += sizeof(long))
677682
diffs |= *cp1++ ^ *cp2++;
678683

679684
return diffs == 0;
@@ -713,7 +718,7 @@ static struct sw_flow *masked_flow_lookup(struct table_instance *ti,
713718
(*n_mask_hit)++;
714719

715720
hlist_for_each_entry_rcu(flow, head, flow_table.node[ti->node_ver],
716-
lockdep_ovsl_is_held()) {
721+
lockdep_ovsl_is_held()) {
717722
if (flow->mask == mask && flow->flow_table.hash == hash &&
718723
flow_cmp_masked_key(flow, &masked_key, &mask->range))
719724
return flow;
@@ -897,7 +902,8 @@ static bool ovs_flow_cmp_ufid(const struct sw_flow *flow,
897902
return !memcmp(flow->id.ufid, sfid->ufid, sfid->ufid_len);
898903
}
899904

900-
bool ovs_flow_cmp(const struct sw_flow *flow, const struct sw_flow_match *match)
905+
bool ovs_flow_cmp(const struct sw_flow *flow,
906+
const struct sw_flow_match *match)
901907
{
902908
if (ovs_identifier_is_ufid(&flow->id))
903909
return flow_cmp_masked_key(flow, match->key, &match->range);
@@ -916,7 +922,7 @@ struct sw_flow *ovs_flow_tbl_lookup_ufid(struct flow_table *tbl,
916922
hash = ufid_hash(ufid);
917923
head = find_bucket(ti, hash);
918924
hlist_for_each_entry_rcu(flow, head, ufid_table.node[ti->node_ver],
919-
lockdep_ovsl_is_held()) {
925+
lockdep_ovsl_is_held()) {
920926
if (flow->ufid_table.hash == hash &&
921927
ovs_flow_cmp_ufid(flow, ufid))
922928
return flow;
@@ -1107,7 +1113,7 @@ void ovs_flow_masks_rebalance(struct flow_table *table)
11071113
if (!masks_and_count)
11081114
return;
11091115

1110-
for (i = 0; i < ma->max; i++) {
1116+
for (i = 0; i < ma->max; i++) {
11111117
struct sw_flow_mask *mask;
11121118
unsigned int start;
11131119
int cpu;

‎net/openvswitch/vport.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ struct vport *ovs_vport_locate(const struct net *net, const char *name)
9898
struct vport *vport;
9999

100100
hlist_for_each_entry_rcu(vport, bucket, hash_node,
101-
lockdep_ovsl_is_held())
101+
lockdep_ovsl_is_held())
102102
if (!strcmp(name, ovs_vport_name(vport)) &&
103103
net_eq(ovs_dp_get_net(vport->dp), net))
104104
return vport;
@@ -118,7 +118,7 @@ struct vport *ovs_vport_locate(const struct net *net, const char *name)
118118
* vport_free().
119119
*/
120120
struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops,
121-
const struct vport_parms *parms)
121+
const struct vport_parms *parms)
122122
{
123123
struct vport *vport;
124124
size_t alloc_size;
@@ -397,7 +397,8 @@ int ovs_vport_get_upcall_portids(const struct vport *vport,
397397
*
398398
* Returns the portid of the target socket. Must be called with rcu_read_lock.
399399
*/
400-
u32 ovs_vport_find_upcall_portid(const struct vport *vport, struct sk_buff *skb)
400+
u32 ovs_vport_find_upcall_portid(const struct vport *vport,
401+
struct sk_buff *skb)
401402
{
402403
struct vport_portids *ids;
403404
u32 ids_index;

0 commit comments

Comments
 (0)