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

TOMOYO Linux Cross Reference
Linux/net/sched/sch_frag.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ 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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /net/sched/sch_frag.c (Version linux-6.12-rc7) and /net/sched/sch_frag.c (Version linux-4.13.16)


  1 // SPDX-License-Identifier: GPL-2.0 OR Linux-O      1 
  2 #include <linux/if_vlan.h>                        
  3 #include <net/netlink.h>                          
  4 #include <net/sch_generic.h>                      
  5 #include <net/pkt_sched.h>                        
  6 #include <net/dst.h>                              
  7 #include <net/ip.h>                               
  8 #include <net/ip6_fib.h>                          
  9                                                   
 10 struct sch_frag_data {                            
 11         unsigned long dst;                        
 12         struct qdisc_skb_cb cb;                   
 13         __be16 inner_protocol;                    
 14         u16 vlan_tci;                             
 15         __be16 vlan_proto;                        
 16         unsigned int l2_len;                      
 17         u8 l2_data[VLAN_ETH_HLEN];                
 18         int (*xmit)(struct sk_buff *skb);         
 19 };                                                
 20                                                   
 21 static DEFINE_PER_CPU(struct sch_frag_data, sc    
 22                                                   
 23 static int sch_frag_xmit(struct net *net, stru    
 24 {                                                 
 25         struct sch_frag_data *data = this_cpu_    
 26                                                   
 27         if (skb_cow_head(skb, data->l2_len) <     
 28                 kfree_skb(skb);                   
 29                 return -ENOMEM;                   
 30         }                                         
 31                                                   
 32         __skb_dst_copy(skb, data->dst);           
 33         *qdisc_skb_cb(skb) = data->cb;            
 34         skb->inner_protocol = data->inner_prot    
 35         if (data->vlan_tci & VLAN_CFI_MASK)       
 36                 __vlan_hwaccel_put_tag(skb, da    
 37                                        data->v    
 38         else                                      
 39                 __vlan_hwaccel_clear_tag(skb);    
 40                                                   
 41         /* Reconstruct the MAC header.  */        
 42         skb_push(skb, data->l2_len);              
 43         memcpy(skb->data, &data->l2_data, data    
 44         skb_postpush_rcsum(skb, skb->data, dat    
 45         skb_reset_mac_header(skb);                
 46                                                   
 47         return data->xmit(skb);                   
 48 }                                                 
 49                                                   
 50 static void sch_frag_prepare_frag(struct sk_bu    
 51                                   int (*xmit)(    
 52 {                                                 
 53         unsigned int hlen = skb_network_offset    
 54         struct sch_frag_data *data;               
 55                                                   
 56         data = this_cpu_ptr(&sch_frag_data_sto    
 57         data->dst = skb->_skb_refdst;             
 58         data->cb = *qdisc_skb_cb(skb);            
 59         data->xmit = xmit;                        
 60         data->inner_protocol = skb->inner_prot    
 61         if (skb_vlan_tag_present(skb))            
 62                 data->vlan_tci = skb_vlan_tag_    
 63         else                                      
 64                 data->vlan_tci = 0;               
 65         data->vlan_proto = skb->vlan_proto;       
 66         data->l2_len = hlen;                      
 67         memcpy(&data->l2_data, skb->data, hlen    
 68                                                   
 69         memset(IPCB(skb), 0, sizeof(struct ine    
 70         skb_pull(skb, hlen);                      
 71 }                                                 
 72                                                   
 73 static unsigned int                               
 74 sch_frag_dst_get_mtu(const struct dst_entry *d    
 75 {                                                 
 76         return dst->dev->mtu;                     
 77 }                                                 
 78                                                   
 79 static struct dst_ops sch_frag_dst_ops = {        
 80         .family = AF_UNSPEC,                      
 81         .mtu = sch_frag_dst_get_mtu,              
 82 };                                                
 83                                                   
 84 static int sch_fragment(struct net *net, struc    
 85                         u16 mru, int (*xmit)(s    
 86 {                                                 
 87         int ret = -1;                             
 88                                                   
 89         if (skb_network_offset(skb) > VLAN_ETH    
 90                 net_warn_ratelimited("L2 heade    
 91                 goto err;                         
 92         }                                         
 93                                                   
 94         if (skb_protocol(skb, true) == htons(E    
 95                 struct rtable sch_frag_rt = {     
 96                 unsigned long orig_dst;           
 97                                                   
 98                 sch_frag_prepare_frag(skb, xmi    
 99                 dst_init(&sch_frag_rt.dst, &sc    
100                          DST_OBSOLETE_NONE, DS    
101                 sch_frag_rt.dst.dev = skb->dev    
102                                                   
103                 orig_dst = skb->_skb_refdst;      
104                 skb_dst_set_noref(skb, &sch_fr    
105                 IPCB(skb)->frag_max_size = mru    
106                                                   
107                 ret = ip_do_fragment(net, skb-    
108                 refdst_drop(orig_dst);            
109         } else if (skb_protocol(skb, true) ==     
110                 unsigned long orig_dst;           
111                 struct rt6_info sch_frag_rt;      
112                                                   
113                 sch_frag_prepare_frag(skb, xmi    
114                 memset(&sch_frag_rt, 0, sizeof    
115                 dst_init(&sch_frag_rt.dst, &sc    
116                          DST_OBSOLETE_NONE, DS    
117                 sch_frag_rt.dst.dev = skb->dev    
118                                                   
119                 orig_dst = skb->_skb_refdst;      
120                 skb_dst_set_noref(skb, &sch_fr    
121                 IP6CB(skb)->frag_max_size = mr    
122                                                   
123                 ret = ipv6_stub->ipv6_fragment    
124                                                   
125                 refdst_drop(orig_dst);            
126         } else {                                  
127                 net_warn_ratelimited("Fail fra    
128                                      netdev_na    
129                                      ntohs(skb    
130                                      skb->dev-    
131                 goto err;                         
132         }                                         
133                                                   
134         return ret;                               
135 err:                                              
136         kfree_skb(skb);                           
137         return ret;                               
138 }                                                 
139                                                   
140 int sch_frag_xmit_hook(struct sk_buff *skb, in    
141 {                                                 
142         u16 mru = tc_skb_cb(skb)->mru;            
143         int err;                                  
144                                                   
145         if (mru && skb->len > mru + skb->dev->    
146                 err = sch_fragment(dev_net(skb    
147         else                                      
148                 err = xmit(skb);                  
149                                                   
150         return err;                               
151 }                                                 
152 EXPORT_SYMBOL_GPL(sch_frag_xmit_hook);            
153                                                   

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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.

sflogo.php