Skip to content

Commit 9b8ff51

Browse files
David Aherndavem330
authored andcommitted
net: Make table id type u32
A number of VRF patches used 'int' for table id. It should be u32 to be consistent with the rest of the stack. Fixes: 4e3c899 ("net: Introduce VRF related flags and helpers") 15be405 ("net: Add inet_addr lookup by table") 30bbaa1 ("net: Fix up inet_addr_type checks") 021dd3b ("net: Add routes to the table associated with the device") dc028da ("inet: Move VRF table lookup to inlined function") f6d3c19 ("net: FIB tracepoints") Signed-off-by: David Ahern <[email protected]> Reviewed-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 63b6c13 commit 9b8ff51

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

include/net/route.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void ipv4_sk_redirect(struct sk_buff *skb, struct sock *sk);
188188
void ip_rt_send_redirect(struct sk_buff *skb);
189189

190190
unsigned int inet_addr_type(struct net *net, __be32 addr);
191-
unsigned int inet_addr_type_table(struct net *net, __be32 addr, int tb_id);
191+
unsigned int inet_addr_type_table(struct net *net, __be32 addr, u32 tb_id);
192192
unsigned int inet_dev_addr_type(struct net *net, const struct net_device *dev,
193193
__be32 addr);
194194
unsigned int inet_addr_type_dev_table(struct net *net,

include/net/vrf.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ static inline int vrf_master_ifindex(const struct net_device *dev)
6666
}
6767

6868
/* called with rcu_read_lock */
69-
static inline int vrf_dev_table_rcu(const struct net_device *dev)
69+
static inline u32 vrf_dev_table_rcu(const struct net_device *dev)
7070
{
71-
int tb_id = 0;
71+
u32 tb_id = 0;
7272

7373
if (dev) {
7474
struct net_vrf_dev *vrf_ptr;
@@ -80,9 +80,9 @@ static inline int vrf_dev_table_rcu(const struct net_device *dev)
8080
return tb_id;
8181
}
8282

83-
static inline int vrf_dev_table(const struct net_device *dev)
83+
static inline u32 vrf_dev_table(const struct net_device *dev)
8484
{
85-
int tb_id;
85+
u32 tb_id;
8686

8787
rcu_read_lock();
8888
tb_id = vrf_dev_table_rcu(dev);
@@ -91,10 +91,10 @@ static inline int vrf_dev_table(const struct net_device *dev)
9191
return tb_id;
9292
}
9393

94-
static inline int vrf_dev_table_ifindex(struct net *net, int ifindex)
94+
static inline u32 vrf_dev_table_ifindex(struct net *net, int ifindex)
9595
{
9696
struct net_device *dev;
97-
int tb_id = 0;
97+
u32 tb_id = 0;
9898

9999
if (!ifindex)
100100
return 0;
@@ -111,9 +111,9 @@ static inline int vrf_dev_table_ifindex(struct net *net, int ifindex)
111111
}
112112

113113
/* called with rtnl */
114-
static inline int vrf_dev_table_rtnl(const struct net_device *dev)
114+
static inline u32 vrf_dev_table_rtnl(const struct net_device *dev)
115115
{
116-
int tb_id = 0;
116+
u32 tb_id = 0;
117117

118118
if (dev) {
119119
struct net_vrf_dev *vrf_ptr;
@@ -149,22 +149,22 @@ static inline int vrf_master_ifindex(const struct net_device *dev)
149149
return 0;
150150
}
151151

152-
static inline int vrf_dev_table_rcu(const struct net_device *dev)
152+
static inline u32 vrf_dev_table_rcu(const struct net_device *dev)
153153
{
154154
return 0;
155155
}
156156

157-
static inline int vrf_dev_table(const struct net_device *dev)
157+
static inline u32 vrf_dev_table(const struct net_device *dev)
158158
{
159159
return 0;
160160
}
161161

162-
static inline int vrf_dev_table_ifindex(struct net *net, int ifindex)
162+
static inline u32 vrf_dev_table_ifindex(struct net *net, int ifindex)
163163
{
164164
return 0;
165165
}
166166

167-
static inline int vrf_dev_table_rtnl(const struct net_device *dev)
167+
static inline u32 vrf_dev_table_rtnl(const struct net_device *dev)
168168
{
169169
return 0;
170170
}

include/trace/events/fib.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
TRACE_EVENT(fib_table_lookup,
1313

14-
TP_PROTO(int tb_id, const struct flowi4 *flp),
14+
TP_PROTO(u32 tb_id, const struct flowi4 *flp),
1515

1616
TP_ARGS(tb_id, flp),
1717

1818
TP_STRUCT__entry(
19-
__field( int, tb_id )
19+
__field( u32, tb_id )
2020
__field( int, oif )
2121
__field( int, iif )
2222
__field( __u8, tos )
@@ -43,7 +43,7 @@ TRACE_EVENT(fib_table_lookup,
4343
*p32 = flp->daddr;
4444
),
4545

46-
TP_printk("table %d oif %d iif %d src %pI4 dst %pI4 tos %d scope %d flags %x",
46+
TP_printk("table %u oif %d iif %d src %pI4 dst %pI4 tos %d scope %d flags %x",
4747
__entry->tb_id, __entry->oif, __entry->iif,
4848
__entry->src, __entry->dst, __entry->tos, __entry->scope,
4949
__entry->flags)

net/ipv4/af_inet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
428428
struct net *net = sock_net(sk);
429429
unsigned short snum;
430430
int chk_addr_ret;
431-
int tb_id = RT_TABLE_LOCAL;
431+
u32 tb_id = RT_TABLE_LOCAL;
432432
int err;
433433

434434
/* If the socket has its own bind function then use it. (RAW) */

net/ipv4/fib_frontend.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ void fib_flush_external(struct net *net)
213213
*/
214214
static inline unsigned int __inet_dev_addr_type(struct net *net,
215215
const struct net_device *dev,
216-
__be32 addr, int tb_id)
216+
__be32 addr, u32 tb_id)
217217
{
218218
struct flowi4 fl4 = { .daddr = addr };
219219
struct fib_result res;
@@ -240,7 +240,7 @@ static inline unsigned int __inet_dev_addr_type(struct net *net,
240240
return ret;
241241
}
242242

243-
unsigned int inet_addr_type_table(struct net *net, __be32 addr, int tb_id)
243+
unsigned int inet_addr_type_table(struct net *net, __be32 addr, u32 tb_id)
244244
{
245245
return __inet_dev_addr_type(net, NULL, addr, tb_id);
246246
}
@@ -255,7 +255,7 @@ EXPORT_SYMBOL(inet_addr_type);
255255
unsigned int inet_dev_addr_type(struct net *net, const struct net_device *dev,
256256
__be32 addr)
257257
{
258-
int rt_table = vrf_dev_table(dev) ? : RT_TABLE_LOCAL;
258+
u32 rt_table = vrf_dev_table(dev) ? : RT_TABLE_LOCAL;
259259

260260
return __inet_dev_addr_type(net, dev, addr, rt_table);
261261
}
@@ -268,7 +268,7 @@ unsigned int inet_addr_type_dev_table(struct net *net,
268268
const struct net_device *dev,
269269
__be32 addr)
270270
{
271-
int rt_table = vrf_dev_table(dev) ? : RT_TABLE_LOCAL;
271+
u32 rt_table = vrf_dev_table(dev) ? : RT_TABLE_LOCAL;
272272

273273
return __inet_dev_addr_type(net, NULL, addr, rt_table);
274274
}
@@ -803,7 +803,7 @@ static int inet_dump_fib(struct sk_buff *skb, struct netlink_callback *cb)
803803
static void fib_magic(int cmd, int type, __be32 dst, int dst_len, struct in_ifaddr *ifa)
804804
{
805805
struct net *net = dev_net(ifa->ifa_dev->dev);
806-
int tb_id = vrf_dev_table_rtnl(ifa->ifa_dev->dev);
806+
u32 tb_id = vrf_dev_table_rtnl(ifa->ifa_dev->dev);
807807
struct fib_table *tb;
808808
struct fib_config cfg = {
809809
.fc_protocol = RTPROT_KERNEL,

net/ipv4/fib_semantics.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ static bool fib_valid_prefsrc(struct fib_config *cfg, __be32 fib_prefsrc)
863863
{
864864
if (cfg->fc_type != RTN_LOCAL || !cfg->fc_dst ||
865865
fib_prefsrc != cfg->fc_dst) {
866-
int tb_id = cfg->fc_table;
866+
u32 tb_id = cfg->fc_table;
867867

868868
if (tb_id == RT_TABLE_MAIN)
869869
tb_id = RT_TABLE_LOCAL;

0 commit comments

Comments
 (0)