debuggers.hg
changeset 21220:373daaeb636e
Remus: make ebt_imq and sch_queue compatible with pvops
Signed-off-by: Brendan Cully <brendan@cs.ubc.ca>
Signed-off-by: Brendan Cully <brendan@cs.ubc.ca>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Thu Apr 15 08:42:08 2010 +0100 (2010-04-15) |
parents | ecdc14634425 |
children | acba53182435 |
files | tools/remus/kmod/Makefile tools/remus/kmod/ebt_imq.c tools/remus/kmod/ebt_imq.h tools/remus/kmod/sch_queue.c |
line diff
1.1 --- a/tools/remus/kmod/Makefile Wed Apr 14 13:35:05 2010 +0100 1.2 +++ b/tools/remus/kmod/Makefile Thu Apr 15 08:42:08 2010 +0100 1.3 @@ -9,6 +9,9 @@ endif 1.4 ifeq ($(KERNELS),linux-2.6-xen0) 1.5 LINUX_VER=2.6.18-xen0 1.6 endif 1.7 +ifeq ($(KERNELS),linux-2.6-pvops) 1.8 +LINUX_VER=2.6-pvops 1.9 +endif 1.10 1.11 KERNELDIR ?= $(XEN_ROOT)/build-linux-$(LINUX_VER)_$(XEN_TARGET_ARCH) 1.12
2.1 --- a/tools/remus/kmod/ebt_imq.c Wed Apr 14 13:35:05 2010 +0100 2.2 +++ b/tools/remus/kmod/ebt_imq.c Thu Apr 15 08:42:08 2010 +0100 2.3 @@ -1,9 +1,19 @@ 2.4 +#include <linux/version.h> 2.5 +#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,18) 2.6 +# define OLDKERNEL 2.7 +#endif 2.8 + 2.9 #include <linux/module.h> 2.10 #include <linux/skbuff.h> 2.11 +#ifndef OLDKERNEL 2.12 +# include <linux/netfilter/x_tables.h> 2.13 +#endif 2.14 #include <linux/netfilter_bridge/ebtables.h> 2.15 #include <linux/netdevice.h> 2.16 #include "ebt_imq.h" 2.17 2.18 +#ifdef OLDKERNEL 2.19 + 2.20 static int ebt_target_imq(struct sk_buff **pskb, unsigned int hooknr, 2.21 const struct net_device *in, const struct net_device *out, 2.22 const void *data, unsigned int datalen) 2.23 @@ -21,25 +31,66 @@ static int ebt_target_imq_check(const ch 2.24 return 0; 2.25 } 2.26 2.27 -static struct ebt_target imq_target = 2.28 +static struct ebt_target ebt_imq_target = 2.29 { 2.30 - .name = "imq", 2.31 - .target = ebt_target_imq, 2.32 + .name = EBT_IMQ_TARGET, 2.33 + .target = ebt_target_imq, 2.34 .check = ebt_target_imq_check, 2.35 .me = THIS_MODULE, 2.36 }; 2.37 2.38 -static int __init init(void) 2.39 +static int __init ebt_imq_init(void) 2.40 +{ 2.41 + return ebt_register_target(&ebt_imq_target); 2.42 +} 2.43 + 2.44 +static void __exit ebt_imq_fini(void) 2.45 { 2.46 - return ebt_register_target(&imq_target); 2.47 + ebt_unregister_target(&ebt_imq_target); 2.48 +} 2.49 + 2.50 +#else /* OLDKERNEL */ 2.51 + 2.52 +static unsigned int 2.53 +ebt_imq_tg(struct sk_buff *skb, const struct xt_target_param *par) 2.54 +{ 2.55 + const struct ebt_imq_info *info = par->targinfo; 2.56 + 2.57 + if (!skb_make_writable(skb, 0)) 2.58 + return EBT_DROP; 2.59 + 2.60 + skb->imq_flags = info->todev | IMQ_F_ENQUEUE; 2.61 + 2.62 + return EBT_CONTINUE; 2.63 } 2.64 2.65 -static void __exit fini(void) 2.66 +static bool ebt_imq_tg_check(const struct xt_tgchk_param *par) 2.67 { 2.68 - ebt_unregister_target(&imq_target); 2.69 + return true; 2.70 } 2.71 2.72 +static struct xt_target ebt_imq_target __read_mostly = { 2.73 + .name = EBT_IMQ_TARGET, 2.74 + .revision = 0, 2.75 + .family = NFPROTO_BRIDGE, 2.76 + .target = ebt_imq_tg, 2.77 + .checkentry = ebt_imq_tg_check, 2.78 + .targetsize = XT_ALIGN(sizeof(struct ebt_imq_info)), 2.79 + .me = THIS_MODULE, 2.80 +}; 2.81 2.82 -module_init(init); 2.83 -module_exit(fini); 2.84 +static int __init ebt_imq_init(void) 2.85 +{ 2.86 + return xt_register_target(&ebt_imq_target); 2.87 +} 2.88 + 2.89 +static void __init ebt_imq_fini(void) 2.90 +{ 2.91 + xt_unregister_target(&ebt_imq_target); 2.92 +} 2.93 + 2.94 +#endif /* OLDKERNEL */ 2.95 + 2.96 +module_init(ebt_imq_init); 2.97 +module_exit(ebt_imq_fini); 2.98 MODULE_LICENSE("GPL");
3.1 --- a/tools/remus/kmod/ebt_imq.h Wed Apr 14 13:35:05 2010 +0100 3.2 +++ b/tools/remus/kmod/ebt_imq.h Thu Apr 15 08:42:08 2010 +0100 3.3 @@ -1,10 +1,14 @@ 3.4 #ifndef __LINUX_BRIDGE_EBT_IMQ_H 3.5 #define __LINUX_BRIDGE_EBT_IMQ_H 3.6 3.7 -#define IMQ_F_ENQUEUE 0x80 3.8 +#ifdef OLDKERNEL 3.9 +# define IMQ_F_ENQUEUE 0x80 3.10 +#endif 3.11 3.12 struct ebt_imq_info 3.13 { 3.14 unsigned int todev; 3.15 }; 3.16 +#define EBT_IMQ_TARGET "imq" 3.17 + 3.18 #endif
4.1 --- a/tools/remus/kmod/sch_queue.c Wed Apr 14 13:35:05 2010 +0100 4.2 +++ b/tools/remus/kmod/sch_queue.c Thu Apr 15 08:42:08 2010 +0100 4.3 @@ -16,7 +16,14 @@ 4.4 * So it supports two operations, barrier and release. 4.5 */ 4.6 4.7 -#include <linux/config.h> 4.8 +#include <linux/version.h> 4.9 +#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,18) 4.10 +# define OLDKERNEL 4.11 +#endif 4.12 + 4.13 +#ifdef OLDKERNEL 4.14 +# include <linux/config.h> 4.15 +#endif 4.16 #include <linux/module.h> 4.17 #include <linux/types.h> 4.18 #include <linux/kernel.h> 4.19 @@ -25,6 +32,17 @@ 4.20 #include <linux/skbuff.h> 4.21 #include <net/pkt_sched.h> 4.22 4.23 +#ifdef OLDKERNEL 4.24 +# define compatnlattr rtattr 4.25 +# define compatnllen RTA_PAYLOAD 4.26 +# define compatnldata RTA_DATA 4.27 +#else 4.28 +# include <xen/features.h> 4.29 +# define compatnlattr nlattr 4.30 +# define compatnllen nla_len 4.31 +# define compatnldata nla_data 4.32 +#endif 4.33 + 4.34 /* xenbus directory */ 4.35 #define FIFO_BUF (10*1024*1024) 4.36 4.37 @@ -43,6 +61,7 @@ struct tc_queue_qopt { 4.38 int action; 4.39 }; 4.40 4.41 +#ifdef OLDKERNEL 4.42 /* borrowed from drivers/xen/netback/loopback.c */ 4.43 #ifdef CONFIG_X86 4.44 static int is_foreign(unsigned long pfn) 4.45 @@ -88,6 +107,12 @@ static int skb_remove_foreign_references 4.46 4.47 return 1; 4.48 } 4.49 +#else /* OLDKERNEL */ 4.50 +static int skb_remove_foreign_references(struct sk_buff *skb) 4.51 +{ 4.52 + return !skb_linearize(skb); 4.53 +} 4.54 +#endif /* OLDKERNEL */ 4.55 4.56 static int queue_enqueue(struct sk_buff *skb, struct Qdisc* sch) 4.57 { 4.58 @@ -112,7 +137,7 @@ static int queue_enqueue(struct sk_buff 4.59 4.60 /* dequeue doesn't actually dequeue until the release command is 4.61 * received. */ 4.62 -static inline struct sk_buff *queue_dequeue(struct Qdisc* sch) 4.63 +static struct sk_buff *queue_dequeue(struct Qdisc* sch) 4.64 { 4.65 struct queue_sched_data *q = qdisc_priv(sch); 4.66 struct sk_buff* peek; 4.67 @@ -145,7 +170,7 @@ static inline struct sk_buff *queue_dequ 4.68 return qdisc_dequeue_head(sch); 4.69 } 4.70 4.71 -static int queue_init(struct Qdisc *sch, struct rtattr *opt) 4.72 +static int queue_init(struct Qdisc *sch, struct compatnlattr *opt) 4.73 { 4.74 sch->flags |= TCQ_F_THROTTLED; 4.75 4.76 @@ -155,7 +180,7 @@ static int queue_init(struct Qdisc *sch, 4.77 /* receives two messages: 4.78 * 0: checkpoint queue (set stop to next packet) 4.79 * 1: dequeue until stop */ 4.80 -static int queue_change(struct Qdisc* sch, struct rtattr* opt) 4.81 +static int queue_change(struct Qdisc* sch, struct compatnlattr* opt) 4.82 { 4.83 struct queue_sched_data *q = qdisc_priv(sch); 4.84 struct tc_queue_qopt* msg; 4.85 @@ -163,10 +188,10 @@ static int queue_change(struct Qdisc* sc 4.86 struct timeval tv; 4.87 */ 4.88 4.89 - if (!opt || RTA_PAYLOAD(opt) < sizeof(*msg)) 4.90 + if (!opt || compatnllen(opt) < sizeof(*msg)) 4.91 return -EINVAL; 4.92 4.93 - msg = RTA_DATA(opt); 4.94 + msg = compatnldata(opt); 4.95 4.96 if (msg->action == TCQ_CHECKPOINT) { 4.97 /* reset stop */ 4.98 @@ -174,7 +199,11 @@ static int queue_change(struct Qdisc* sc 4.99 } else if (msg->action == TCQ_DEQUEUE) { 4.100 /* dequeue */ 4.101 sch->flags &= ~TCQ_F_THROTTLED; 4.102 +#ifdef OLDKERNEL 4.103 netif_schedule(sch->dev); 4.104 +#else 4.105 + netif_schedule_queue(sch->dev_queue); 4.106 +#endif 4.107 /* 4.108 do_gettimeofday(&tv); 4.109 printk("queue release at %lu.%06lu (%d bytes)\n", tv.tv_sec, tv.tv_usec, 4.110 @@ -192,8 +221,11 @@ struct Qdisc_ops queue_qdisc_ops = { 4.111 .priv_size = sizeof(struct queue_sched_data), 4.112 .enqueue = queue_enqueue, 4.113 .dequeue = queue_dequeue, 4.114 - .init = queue_init, 4.115 - .change = queue_change, 4.116 +#ifndef OLDKERNEL 4.117 + .peek = qdisc_peek_head, 4.118 +#endif 4.119 + .init = queue_init, 4.120 + .change = queue_change, 4.121 .owner = THIS_MODULE, 4.122 }; 4.123