~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/l3mdev/l3mdev.c

Version: ~ [ linux-5.14-rc3 ] ~ [ linux-5.13.5 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.53 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.135 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.198 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.240 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.276 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.276 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /net/l3mdev/l3mdev.c (Version linux-4.18.20) and /net/l3mdev/l3mdev.c (Version linux-3.10.108)


  1 /*                                                  1 
  2  * net/l3mdev/l3mdev.c - L3 master device impl    
  3  * Copyright (c) 2015 Cumulus Networks            
  4  * Copyright (c) 2015 David Ahern <dsa@cumulus    
  5  *                                                
  6  * This program is free software; you can redi    
  7  * it under the terms of the GNU General Publi    
  8  * the Free Software Foundation; either versio    
  9  * (at your option) any later version.            
 10  */                                               
 11                                                   
 12 #include <linux/netdevice.h>                      
 13 #include <net/fib_rules.h>                        
 14 #include <net/l3mdev.h>                           
 15                                                   
 16 /**                                               
 17  *      l3mdev_master_ifindex - get index of L    
 18  *      @dev: targeted interface                  
 19  */                                               
 20                                                   
 21 int l3mdev_master_ifindex_rcu(const struct net    
 22 {                                                 
 23         int ifindex = 0;                          
 24                                                   
 25         if (!dev)                                 
 26                 return 0;                         
 27                                                   
 28         if (netif_is_l3_master(dev)) {            
 29                 ifindex = dev->ifindex;           
 30         } else if (netif_is_l3_slave(dev)) {      
 31                 struct net_device *master;        
 32                 struct net_device *_dev = (str    
 33                                                   
 34                 /* netdev_master_upper_dev_get    
 35                  * list_first_or_null_rcu to w    
 36                  * list_first_or_null_rcu does    
 37                  * making changes, just want t    
 38                  * typecast to remove the cons    
 39                  */                               
 40                 master = netdev_master_upper_d    
 41                 if (master)                       
 42                         ifindex = master->ifin    
 43         }                                         
 44                                                   
 45         return ifindex;                           
 46 }                                                 
 47 EXPORT_SYMBOL_GPL(l3mdev_master_ifindex_rcu);     
 48                                                   
 49 /**                                               
 50  *      l3mdev_fib_table - get FIB table id as    
 51  *                             master interfac    
 52  *      @dev: targeted interface                  
 53  */                                               
 54                                                   
 55 u32 l3mdev_fib_table_rcu(const struct net_devi    
 56 {                                                 
 57         u32 tb_id = 0;                            
 58                                                   
 59         if (!dev)                                 
 60                 return 0;                         
 61                                                   
 62         if (netif_is_l3_master(dev)) {            
 63                 if (dev->l3mdev_ops->l3mdev_fi    
 64                         tb_id = dev->l3mdev_op    
 65         } else if (netif_is_l3_slave(dev)) {      
 66                 /* Users of netdev_master_uppe    
 67                  * but current inet_*type func    
 68                  */                               
 69                 struct net_device *_dev = (str    
 70                 const struct net_device *maste    
 71                                                   
 72                 master = netdev_master_upper_d    
 73                 if (master &&                     
 74                     master->l3mdev_ops->l3mdev    
 75                         tb_id = master->l3mdev    
 76         }                                         
 77                                                   
 78         return tb_id;                             
 79 }                                                 
 80 EXPORT_SYMBOL_GPL(l3mdev_fib_table_rcu);          
 81                                                   
 82 u32 l3mdev_fib_table_by_index(struct net *net,    
 83 {                                                 
 84         struct net_device *dev;                   
 85         u32 tb_id = 0;                            
 86                                                   
 87         if (!ifindex)                             
 88                 return 0;                         
 89                                                   
 90         rcu_read_lock();                          
 91                                                   
 92         dev = dev_get_by_index_rcu(net, ifinde    
 93         if (dev)                                  
 94                 tb_id = l3mdev_fib_table_rcu(d    
 95                                                   
 96         rcu_read_unlock();                        
 97                                                   
 98         return tb_id;                             
 99 }                                                 
100 EXPORT_SYMBOL_GPL(l3mdev_fib_table_by_index);     
101                                                   
102 /**                                               
103  *      l3mdev_link_scope_lookup - IPv6 route     
104  *                           local and multica    
105  *      @net: network namespace for device ind    
106  *      @fl6: IPv6 flow struct for lookup         
107  */                                               
108                                                   
109 struct dst_entry *l3mdev_link_scope_lookup(str    
110                                            str    
111 {                                                 
112         struct dst_entry *dst = NULL;             
113         struct net_device *dev;                   
114                                                   
115         if (fl6->flowi6_oif) {                    
116                 rcu_read_lock();                  
117                                                   
118                 dev = dev_get_by_index_rcu(net    
119                 if (dev && netif_is_l3_slave(d    
120                         dev = netdev_master_up    
121                                                   
122                 if (dev && netif_is_l3_master(    
123                     dev->l3mdev_ops->l3mdev_li    
124                         dst = dev->l3mdev_ops-    
125                                                   
126                 rcu_read_unlock();                
127         }                                         
128                                                   
129         return dst;                               
130 }                                                 
131 EXPORT_SYMBOL_GPL(l3mdev_link_scope_lookup);      
132                                                   
133 /**                                               
134  *      l3mdev_fib_rule_match - Determine if f    
135  *                              L3 master devi    
136  *      @net: network namespace for device ind    
137  *      @fl:  flow struct                         
138  */                                               
139                                                   
140 int l3mdev_fib_rule_match(struct net *net, str    
141                           struct fib_lookup_ar    
142 {                                                 
143         struct net_device *dev;                   
144         int rc = 0;                               
145                                                   
146         rcu_read_lock();                          
147                                                   
148         dev = dev_get_by_index_rcu(net, fl->fl    
149         if (dev && netif_is_l3_master(dev) &&     
150             dev->l3mdev_ops->l3mdev_fib_table)    
151                 arg->table = dev->l3mdev_ops->    
152                 rc = 1;                           
153                 goto out;                         
154         }                                         
155                                                   
156         dev = dev_get_by_index_rcu(net, fl->fl    
157         if (dev && netif_is_l3_master(dev) &&     
158             dev->l3mdev_ops->l3mdev_fib_table)    
159                 arg->table = dev->l3mdev_ops->    
160                 rc = 1;                           
161                 goto out;                         
162         }                                         
163                                                   
164 out:                                              
165         rcu_read_unlock();                        
166                                                   
167         return rc;                                
168 }                                                 
169                                                   
170 void l3mdev_update_flow(struct net *net, struc    
171 {                                                 
172         struct net_device *dev;                   
173         int ifindex;                              
174                                                   
175         rcu_read_lock();                          
176                                                   
177         if (fl->flowi_oif) {                      
178                 dev = dev_get_by_index_rcu(net    
179                 if (dev) {                        
180                         ifindex = l3mdev_maste    
181                         if (ifindex) {            
182                                 fl->flowi_oif     
183                                 fl->flowi_flag    
184                                 goto out;         
185                         }                         
186                 }                                 
187         }                                         
188                                                   
189         if (fl->flowi_iif) {                      
190                 dev = dev_get_by_index_rcu(net    
191                 if (dev) {                        
192                         ifindex = l3mdev_maste    
193                         if (ifindex) {            
194                                 fl->flowi_iif     
195                                 fl->flowi_flag    
196                         }                         
197                 }                                 
198         }                                         
199                                                   
200 out:                                              
201         rcu_read_unlock();                        
202 }                                                 
203 EXPORT_SYMBOL_GPL(l3mdev_update_flow);            
204                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp