Advertisement
Guest User

Untitled

a guest
Nov 8th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.53 KB | None | 0 0
  1. --- /mnt/HDD/Projects/Sophos/linux-kernel/net/sched/sch_prio.c
  2. +++ /mnt/HDD/Projects/Sophos/linux-kernel/net/sched/sch_headprio.c
  3.  
  4. @@ -37,9 +37,18 @@
  5.     u32 band = skb->priority;
  6.     struct tcf_result res;
  7.     int err;
  8. +   /*Change start*/   
  9. +   //Storing major number of skb->prio from ffff---- to 0000ffff
  10. +   int majorofband=TC_H_MAJ(band)>>ffz(TC_H_MIN_MASK);
  11. +   //For all child qdisc only  
  12. +   if(likely(majorofband!=0 && majorofband<=q->bands)){  
  13. +                //As per our implementation, all child of this prio are 1:,2:.. bands:
  14. +       band=TC_H_MAKE(sch->handle,majorofband); //changing band from X:Y to Z:X where X=child qdisc Z=prio
  15. +   }
  16. +   /*Change end*/ 
  17.  
  18.     *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;
  19. -   if (TC_H_MAJ(skb->priority) != sch->handle) {
  20. +   if (TC_H_MAJ(band) != sch->handle) { //minor change instead of skb->prio we use band (but ideally band=skb->prio)
  21.         err = tc_classify(skb, q->filter_list, &res);
  22.  
  23.  
  24.  
  25. --- /mnt/HDD/Projects/Sophos/linux-kernel/net/sched/sch_prio.c
  26. +++ /mnt/HDD/Projects/Sophos/linux-kernel/net/sched/sch_leafprio.c
  27. +
  28. +
  29. +extern struct Qdisc_ops sfq_qdisc_ops;
  30. +
  31. +#define XT_DSCP_MASK   0xfc /* 11111100*/
  32. +#define EF_DSCP_VAL    0xb8 /* 10111000*/
  33. +/* Prioritizing Expedited Forwarding traffic */
  34. +static inline char rt_tos2priority_leafprio(u8 tos){
  35. +   if((tos & XT_DSCP_MASK) == EF_DSCP_VAL){
  36. +       return TC_PRIO_INTERACTIVE;
  37. +   }else{
  38. +       return TC_PRIO_BESTEFFORT;
  39. +   }
  40. +}
  41.  
  42.  
  43.  struct prio_sched_data {
  44. @@ -29,14 +49,47 @@
  45.     struct Qdisc *queues[TCQ_PRIO_BANDS];
  46.  };
  47.  
  48. -
  49.  static struct Qdisc *
  50.  prio_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
  51.  {
  52.     struct prio_sched_data *q = qdisc_priv(sch);
  53.     u32 band = skb->priority;
  54.     struct tcf_result res;
  55. -   int err;
  56. +   int err, protooff = 0;
  57. +   struct tcphdr _thdr, *thp;
  58. +
  59. +   if (TC_H_MAJ(skb->priority) != sch->handle){
  60. +       switch (skb->protocol) {
  61. +           case htons(ETH_P_IP):
  62. +               band = rt_tos2priority_leafprio(ip_hdr(skb)->tos);
  63. +               /* favouring tcp pkts with NO_DATA (Ack etc) thereby trying to
  64. +               reduce retransmission due to delayed acks*/
  65. +               if (unlikely((band != TC_PRIO_INTERACTIVE) && (skb->len < 128)
  66. +                       && (ip_hdr(skb)->protocol == IPPROTO_TCP))){
  67. +                   thp = skb_header_pointer(skb, ip_hdr(skb)->ihl<<2, sizeof(_thdr), &_thdr);
  68. +                   /* ip hrd size + tcp hdr size = ip datagram size (i.e. no tcp data)*/      
  69. +                   if(likely(thp && (((ip_hdr(skb)->ihl<<2) + (thp->doff<<2)) == skb->len))){
  70. +                       band = TC_PRIO_INTERACTIVE;
  71. +                   }
  72. +               }
  73. +               break;
  74. +
  75. +           case htons(ETH_P_IPV6):
  76. +               band = rt_tos2priority_leafprio(ipv6_get_dsfield((const struct ipv6hdr *)ipv6_hdr(skb)));
  77. +               /* favouring tcp pkts with NO_DATA (Ack etc) thereby trying to
  78. +               reduce retransmission due to delayed acks, with assumption that
  79. +               there will be limited extra-headers in ipv6 header.*/
  80. +               if (unlikely((band != TC_PRIO_INTERACTIVE) && (skb->len < 128)  
  81. +                       && ipv6_find_hdr(skb, &protooff, IPPROTO_TCP, NULL, NULL) == IPPROTO_TCP)){
  82. +                   thp = skb_header_pointer(skb, protooff, sizeof(_thdr), &_thdr);
  83. +                   /* ip hrd size + tcp hdr size = ip datagram size (i.e. no tcp data)*/      
  84. +                   if(likely(thp && ((protooff + (thp->doff<<2)) == skb->len))){
  85. +                       band = TC_PRIO_INTERACTIVE;
  86. +                   }
  87. +               }
  88. +               break;
  89. +       }
  90. +   }
  91.  
  92.     *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;
  93.     if (TC_H_MAJ(skb->priority) != sch->handle) {
  94. @@ -200,7 +253,7 @@
  95.             struct Qdisc *child, *old;
  96.  
  97.             child = qdisc_create_dflt(sch->dev_queue,
  98. -                         &pfifo_qdisc_ops,
  99. +                         &sfq_qdisc_ops,
  100.                           TC_H_MAKE(sch->handle, i + 1));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement