History

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: 4e3c89920cd3a ("net: Introduce VRF related flags and helpers") 15be405eb2ea9 ("net: Add inet_addr lookup by table") 30bbaa1950055 ("net: Fix up inet_addr_type checks") 021dd3b8a142d ("net: Add routes to the table associated with the device") dc028da54ed35 ("inet: Move VRF table lookup to inlined function") f6d3c19274c74 ("net: FIB tracepoints")

David Ahern committed 11 years ago

Commit 9b8ff511 parent 63b6c136 files · +23 −23Browse files

Unified · Split

6 files
  1. include/net/route.h +1 −1
  2. include/net/vrf.h +12 −12
  3. include/trace/events/fib.h +3 −3
  4. net/ipv4/af_inet.c +1 −1
  5. net/ipv4/fib_frontend.c +5 −5
  6. net/ipv4/fib_semantics.c +1 −1
include/net/route.h+1−1
@@ -188,7 +188,7 @@ void ipv4_sk_redirect(struct sk_buff *skb, struct sock *sk); · 187 unmodified lines
188void ip_rt_send_redirect(struct sk_buff *skb);188void ip_rt_send_redirect(struct sk_buff *skb);
189 189
190unsigned int inet_addr_type(struct net *net, __be32 addr);190unsigned int inet_addr_type(struct net *net, __be32 addr);
191unsigned int inet_addr_type_table(struct net *net, __be32 addr, int tb_id);191unsigned int inet_addr_type_table(struct net *net, __be32 addr, u32 tb_id);
192unsigned int inet_dev_addr_type(struct net *net, const struct net_device *dev,192unsigned int inet_dev_addr_type(struct net *net, const struct net_device *dev,
193 __be32 addr);193 __be32 addr);
194unsigned int inet_addr_type_dev_table(struct net *net,194unsigned int inet_addr_type_dev_table(struct net *net,
include/net/vrf.h+12−12
@@ -66,9 +66,9 @@ static inline int vrf_master_ifindex(const struct net_device *dev) · 65 unmodified lines
66}66}
67 67
68/* called with rcu_read_lock */68/* called with rcu_read_lock */
69static inline int vrf_dev_table_rcu(const struct net_device *dev)69static inline u32 vrf_dev_table_rcu(const struct net_device *dev)
70{70{
71 int tb_id = 0;71 u32 tb_id = 0;
72 72
73 if (dev) {73 if (dev) {
74 struct net_vrf_dev *vrf_ptr;74 struct net_vrf_dev *vrf_ptr;
@@ -80,9 +80,9 @@ static inline int vrf_dev_table_rcu(const struct net_device *dev) · 5 unmodified lines
80 return tb_id;80 return tb_id;
81}81}
82 82
83static inline int vrf_dev_table(const struct net_device *dev)83static inline u32 vrf_dev_table(const struct net_device *dev)
84{84{
85 int tb_id;85 u32 tb_id;
86 86
87 rcu_read_lock();87 rcu_read_lock();
88 tb_id = vrf_dev_table_rcu(dev);88 tb_id = vrf_dev_table_rcu(dev);
@@ -91,10 +91,10 @@ static inline int vrf_dev_table(const struct net_device *dev) · 2 unmodified lines
91 return tb_id;91 return tb_id;
92}92}
93 93
94static inline int vrf_dev_table_ifindex(struct net *net, int ifindex)94static inline u32 vrf_dev_table_ifindex(struct net *net, int ifindex)
95{95{
96 struct net_device *dev;96 struct net_device *dev;
97 int tb_id = 0;97 u32 tb_id = 0;
98 98
99 if (!ifindex)99 if (!ifindex)
100 return 0;100 return 0;
@@ -111,9 +111,9 @@ static inline int vrf_dev_table_ifindex(struct net *net, int ifindex) · 10 unmodified lines
111}111}
112 112
113/* called with rtnl */113/* called with rtnl */
114static inline int vrf_dev_table_rtnl(const struct net_device *dev)114static inline u32 vrf_dev_table_rtnl(const struct net_device *dev)
115{115{
116 int tb_id = 0;116 u32 tb_id = 0;
117 117
118 if (dev) {118 if (dev) {
119 struct net_vrf_dev *vrf_ptr;119 struct net_vrf_dev *vrf_ptr;
@@ -149,22 +149,22 @@ static inline int vrf_master_ifindex(const struct net_device *dev) · 29 unmodified lines
149 return 0;149 return 0;
150}150}
151 151
152static inline int vrf_dev_table_rcu(const struct net_device *dev)152static inline u32 vrf_dev_table_rcu(const struct net_device *dev)
153{153{
154 return 0;154 return 0;
155}155}
156 156
157static inline int vrf_dev_table(const struct net_device *dev)157static inline u32 vrf_dev_table(const struct net_device *dev)
158{158{
159 return 0;159 return 0;
160}160}
161 161
162static inline int vrf_dev_table_ifindex(struct net *net, int ifindex)162static inline u32 vrf_dev_table_ifindex(struct net *net, int ifindex)
163{163{
164 return 0;164 return 0;
165}165}
166 166
167static inline int vrf_dev_table_rtnl(const struct net_device *dev)167static inline u32 vrf_dev_table_rtnl(const struct net_device *dev)
168{168{
169 return 0;169 return 0;
170}170}
include/trace/events/fib.h+3−3
@@ -11,12 +11,12 @@ · 10 unmodified lines
11 11
12TRACE_EVENT(fib_table_lookup,12TRACE_EVENT(fib_table_lookup,
13 13
14 TP_PROTO(int tb_id, const struct flowi4 *flp),14 TP_PROTO(u32 tb_id, const struct flowi4 *flp),
15 15
16 TP_ARGS(tb_id, flp),16 TP_ARGS(tb_id, flp),
17 17
18 TP_STRUCT__entry(18 TP_STRUCT__entry(
19 __field( int, tb_id )19 __field( u32, tb_id )
20 __field( int, oif )20 __field( int, oif )
21 __field( int, iif )21 __field( int, iif )
22 __field( __u8, tos )22 __field( __u8, tos )
@@ -43,7 +43,7 @@ TRACE_EVENT(fib_table_lookup, · 20 unmodified lines
43 *p32 = flp->daddr;43 *p32 = flp->daddr;
44 ),44 ),
45 45
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",
47 __entry->tb_id, __entry->oif, __entry->iif,47 __entry->tb_id, __entry->oif, __entry->iif,
48 __entry->src, __entry->dst, __entry->tos, __entry->scope,48 __entry->src, __entry->dst, __entry->tos, __entry->scope,
49 __entry->flags)49 __entry->flags)
net/ipv4/af_inet.c+1−1
@@ -428,7 +428,7 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) · 427 unmodified lines
428 struct net *net = sock_net(sk);428 struct net *net = sock_net(sk);
429 unsigned short snum;429 unsigned short snum;
430 int chk_addr_ret;430 int chk_addr_ret;
431 int tb_id = RT_TABLE_LOCAL;431 u32 tb_id = RT_TABLE_LOCAL;
432 int err;432 int err;
433 433
434 /* If the socket has its own bind function then use it. (RAW) */434 /* If the socket has its own bind function then use it. (RAW) */
net/ipv4/fib_frontend.c+5−5
@@ -213,7 +213,7 @@ void fib_flush_external(struct net *net) · 212 unmodified lines
213 */213 */
214static inline unsigned int __inet_dev_addr_type(struct net *net,214static inline unsigned int __inet_dev_addr_type(struct net *net,
215 const struct net_device *dev,215 const struct net_device *dev,
216 __be32 addr, int tb_id)216 __be32 addr, u32 tb_id)
217{217{
218 struct flowi4 fl4 = { .daddr = addr };218 struct flowi4 fl4 = { .daddr = addr };
219 struct fib_result res;219 struct fib_result res;
@@ -240,7 +240,7 @@ static inline unsigned int __inet_dev_addr_type(struct net *net, · 20 unmodified lines
240 return ret;240 return ret;
241}241}
242 242
243unsigned int inet_addr_type_table(struct net *net, __be32 addr, int tb_id)243unsigned int inet_addr_type_table(struct net *net, __be32 addr, u32 tb_id)
244{244{
245 return __inet_dev_addr_type(net, NULL, addr, tb_id);245 return __inet_dev_addr_type(net, NULL, addr, tb_id);
246}246}
@@ -255,7 +255,7 @@ EXPORT_SYMBOL(inet_addr_type); · 8 unmodified lines
255unsigned int inet_dev_addr_type(struct net *net, const struct net_device *dev,255unsigned int inet_dev_addr_type(struct net *net, const struct net_device *dev,
256 __be32 addr)256 __be32 addr)
257{257{
258 int rt_table = vrf_dev_table(dev) ? : RT_TABLE_LOCAL;258 u32 rt_table = vrf_dev_table(dev) ? : RT_TABLE_LOCAL;
259 259
260 return __inet_dev_addr_type(net, dev, addr, rt_table);260 return __inet_dev_addr_type(net, dev, addr, rt_table);
261}261}
@@ -268,7 +268,7 @@ unsigned int inet_addr_type_dev_table(struct net *net, · 6 unmodified lines
268 const struct net_device *dev,268 const struct net_device *dev,
269 __be32 addr)269 __be32 addr)
270{270{
271 int rt_table = vrf_dev_table(dev) ? : RT_TABLE_LOCAL;271 u32 rt_table = vrf_dev_table(dev) ? : RT_TABLE_LOCAL;
272 272
273 return __inet_dev_addr_type(net, NULL, addr, rt_table);273 return __inet_dev_addr_type(net, NULL, addr, rt_table);
274}274}
@@ -803,7 +803,7 @@ out: · 528 unmodified lines
803static void fib_magic(int cmd, int type, __be32 dst, int dst_len, struct in_ifaddr *ifa)803static void fib_magic(int cmd, int type, __be32 dst, int dst_len, struct in_ifaddr *ifa)
804{804{
805 struct net *net = dev_net(ifa->ifa_dev->dev);805 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);
807 struct fib_table *tb;807 struct fib_table *tb;
808 struct fib_config cfg = {808 struct fib_config cfg = {
809 .fc_protocol = RTPROT_KERNEL,809 .fc_protocol = RTPROT_KERNEL,
net/ipv4/fib_semantics.c+1−1
@@ -863,7 +863,7 @@ static bool fib_valid_prefsrc(struct fib_config *cfg, __be32 fib_prefsrc) · 862 unmodified lines
863{863{
864 if (cfg->fc_type != RTN_LOCAL || !cfg->fc_dst ||864 if (cfg->fc_type != RTN_LOCAL || !cfg->fc_dst ||
865 fib_prefsrc != cfg->fc_dst) {865 fib_prefsrc != cfg->fc_dst) {
866 int tb_id = cfg->fc_table;866 u32 tb_id = cfg->fc_table;
867 867
868 if (tb_id == RT_TABLE_MAIN)868 if (tb_id == RT_TABLE_MAIN)
869 tb_id = RT_TABLE_LOCAL;869 tb_id = RT_TABLE_LOCAL;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t