Commit cc3c38af authored by David S. Miller's avatar David S. Miller

Merge nuts.ninka.net:/home/davem/src/BK/network-2.5

into nuts.ninka.net:/home/davem/src/BK/net-2.5
parents 3ec0428e 03d08a27
How to use the Linux packet generator module.
1. Enable CONFIG_NET_PKTGEN to compile and build pktgen.o, install it
in the place where insmod may find it.
2. Cut script "ipg" (see below).
3. Edit script to set preferred device and destination IP address.
3a. Create more scripts for different interfaces. Up to thirty-two
pktgen processes can be configured and run at once by using the
32 /proc/net/pktgen/pg* files.
4. Run in shell: ". ipg"
5. After this two commands are defined:
A. "pg" to start generator and to get results.
B. "pgset" to change generator parameters. F.e.
pgset "clone_skb 100" sets the number of coppies of the same packet
will be sent before a new packet is allocated
pgset "clone_skb 0" use multiple SKBs for packet generation
pgset "pkt_size 9014" sets packet size to 9014
pgset "frags 5" packet will consist of 5 fragments
pgset "count 200000" sets number of packets to send, set to zero
for continious sends untill explicitly
stopped.
pgset "ipg 5000" sets artificial gap inserted between packets
to 5000 nanoseconds
pgset "dst 10.0.0.1" sets IP destination address
(BEWARE! This generator is very aggressive!)
pgset "dst_min 10.0.0.1" Same as dst
pgset "dst_max 10.0.0.254" Set the maximum destination IP.
pgset "src_min 10.0.0.1" Set the minimum (or only) source IP.
pgset "src_max 10.0.0.254" Set the maximum source IP.
pgset "dstmac 00:00:00:00:00:00" sets MAC destination address
pgset "srcmac 00:00:00:00:00:00" sets MAC source address
pgset "src_mac_count 1" Sets the number of MACs we'll range through. The
'minimum' MAC is what you set with srcmac.
pgset "dst_mac_count 1" Sets the number of MACs we'll range through. The
'minimum' MAC is what you set with dstmac.
pgset "flag [name]" Set a flag to determine behaviour. Current flags
are: IPSRC_RND #IP Source is random (between min/max),
IPDST_RND, UDPSRC_RND,
UDPDST_RND, MACSRC_RND, MACDST_RND
pgset "udp_src_min 9" set UDP source port min, If < udp_src_max, then
cycle through the port range.
pgset "udp_src_max 9" set UDP source port max.
pgset "udp_dst_min 9" set UDP destination port min, If < udp_dst_max, then
cycle through the port range.
pgset "udp_dst_max 9" set UDP destination port max.
pgset stop aborts injection
Also, ^C aborts generator.
---- cut here
#! /bin/sh
modprobe pktgen
PGDEV=/proc/net/pktgen/pg0
function pgset() {
local result
echo $1 > $PGDEV
result=`cat $PGDEV | fgrep "Result: OK:"`
if [ "$result" = "" ]; then
cat $PGDEV | fgrep Result:
fi
}
function pg() {
echo inject > $PGDEV
cat $PGDEV
}
pgset "odev eth0"
pgset "dst 0.0.0.0"
---- cut here
...@@ -67,9 +67,10 @@ static int crypto_init_flags(struct crypto_tfm *tfm, u32 flags) ...@@ -67,9 +67,10 @@ static int crypto_init_flags(struct crypto_tfm *tfm, u32 flags)
return crypto_init_compress_flags(tfm, flags); return crypto_init_compress_flags(tfm, flags);
default: default:
BUG(); break;
} }
BUG();
return -EINVAL; return -EINVAL;
} }
...@@ -99,13 +100,7 @@ struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags) ...@@ -99,13 +100,7 @@ struct crypto_tfm *crypto_alloc_tfm(const char *name, u32 flags)
struct crypto_tfm *tfm = NULL; struct crypto_tfm *tfm = NULL;
struct crypto_alg *alg; struct crypto_alg *alg;
alg = crypto_alg_lookup(name); alg = crypto_alg_mod_lookup(name);
#ifdef CONFIG_KMOD
if (alg == NULL) {
crypto_alg_autoload(name);
alg = crypto_alg_lookup(name);
}
#endif
if (alg == NULL) if (alg == NULL)
goto out; goto out;
...@@ -207,6 +202,19 @@ int crypto_unregister_alg(struct crypto_alg *alg) ...@@ -207,6 +202,19 @@ int crypto_unregister_alg(struct crypto_alg *alg)
return ret; return ret;
} }
int crypto_alg_available(const char *name, u32 flags)
{
int ret = 0;
struct crypto_alg *alg = crypto_alg_mod_lookup(name);
if (alg) {
crypto_alg_put(alg);
ret = 1;
}
return ret;
}
static void *c_start(struct seq_file *m, loff_t *pos) static void *c_start(struct seq_file *m, loff_t *pos)
{ {
struct list_head *v; struct list_head *v;
...@@ -296,3 +304,4 @@ EXPORT_SYMBOL_GPL(crypto_register_alg); ...@@ -296,3 +304,4 @@ EXPORT_SYMBOL_GPL(crypto_register_alg);
EXPORT_SYMBOL_GPL(crypto_unregister_alg); EXPORT_SYMBOL_GPL(crypto_unregister_alg);
EXPORT_SYMBOL_GPL(crypto_alloc_tfm); EXPORT_SYMBOL_GPL(crypto_alloc_tfm);
EXPORT_SYMBOL_GPL(crypto_free_tfm); EXPORT_SYMBOL_GPL(crypto_free_tfm);
EXPORT_SYMBOL_GPL(crypto_alg_available);
...@@ -25,3 +25,13 @@ void crypto_alg_autoload(const char *name) ...@@ -25,3 +25,13 @@ void crypto_alg_autoload(const char *name)
{ {
request_module(name); request_module(name);
} }
struct crypto_alg *crypto_alg_mod_lookup(const char *name)
{
struct crypto_alg *alg = crypto_alg_lookup(name);
if (alg == NULL) {
crypto_alg_autoload(name);
alg = crypto_alg_lookup(name);
}
return alg;
}
...@@ -35,13 +35,21 @@ static inline void crypto_yield(struct crypto_tfm *tfm) ...@@ -35,13 +35,21 @@ static inline void crypto_yield(struct crypto_tfm *tfm)
cond_resched(); cond_resched();
} }
static inline int crypto_cipher_flags(u32 flags) static inline u32 crypto_cipher_flags(u32 flags)
{ {
return flags & (CRYPTO_TFM_MODE_MASK|CRYPTO_TFM_REQ_WEAK_KEY); return flags & (CRYPTO_TFM_MODE_MASK|CRYPTO_TFM_REQ_WEAK_KEY);
} }
struct crypto_alg *crypto_alg_lookup(const char *name);
#ifdef CONFIG_KMOD #ifdef CONFIG_KMOD
void crypto_alg_autoload(const char *name); void crypto_alg_autoload(const char *name);
struct crypto_alg *crypto_alg_mod_lookup(const char *name);
#else
static inline struct crypto_alg *crypto_alg_mod_lookup(const char *name)
{
return crypto_alg_lookup(name);
}
#endif #endif
int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags); int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags);
......
...@@ -46,6 +46,8 @@ static int mode = 0; ...@@ -46,6 +46,8 @@ static int mode = 0;
static char *xbuf; static char *xbuf;
static char *tvmem; static char *tvmem;
static char *check[] = { "des", "md5", "des3_ede", "rot13", "sha1", NULL };
static void static void
hexdump(unsigned char *buf, unsigned int len) hexdump(unsigned char *buf, unsigned int len)
{ {
...@@ -1299,6 +1301,19 @@ test_des3_ede(void) ...@@ -1299,6 +1301,19 @@ test_des3_ede(void)
crypto_free_tfm(tfm); crypto_free_tfm(tfm);
} }
static void
test_available(void)
{
char **name = check;
while (*name) {
printk("alg %s ", *name);
printk((crypto_alg_available(*name, 0)) ?
"found\n" : "not found\n");
name++;
}
}
static void static void
do_test(void) do_test(void)
{ {
...@@ -1332,6 +1347,10 @@ do_test(void) ...@@ -1332,6 +1347,10 @@ do_test(void)
test_md4(); test_md4();
break; break;
case 100:
test_available();
break;
default: default:
/* useful for debugging */ /* useful for debugging */
printk("not testing anything\n"); printk("not testing anything\n");
......
...@@ -111,6 +111,11 @@ struct crypto_alg { ...@@ -111,6 +111,11 @@ struct crypto_alg {
int crypto_register_alg(struct crypto_alg *alg); int crypto_register_alg(struct crypto_alg *alg);
int crypto_unregister_alg(struct crypto_alg *alg); int crypto_unregister_alg(struct crypto_alg *alg);
/*
* Algorithm query interface.
*/
int crypto_alg_available(const char *name, u32 flags);
/* /*
* Transforms: user-instantiated objects which encapsulate algorithms * Transforms: user-instantiated objects which encapsulate algorithms
* and core processing logic. Managed via crypto_alloc_tfm() and * and core processing logic. Managed via crypto_alloc_tfm() and
......
...@@ -57,7 +57,8 @@ static struct rtable __fake_rtable = { ...@@ -57,7 +57,8 @@ static struct rtable __fake_rtable = {
dst: { dst: {
__refcnt: ATOMIC_INIT(1), __refcnt: ATOMIC_INIT(1),
dev: &__fake_net_device, dev: &__fake_net_device,
pmtu: 1500 path: &__fake_rtable.u.dst,
metrics: {[RTAX_MTU] 1500},
} }
}, },
...@@ -109,8 +110,8 @@ static void __br_dnat_complain(void) ...@@ -109,8 +110,8 @@ static void __br_dnat_complain(void)
* Let us now consider the case that ip_route_input() fails: * Let us now consider the case that ip_route_input() fails:
* *
* After a "echo '0' > /proc/sys/net/ipv4/ip_forward" ip_route_input() * After a "echo '0' > /proc/sys/net/ipv4/ip_forward" ip_route_input()
* will fail, while ip_route_output() will return success. The source * will fail, while __ip_route_output_key() will return success. The source
* address for ip_route_output() is set to zero, so ip_route_output() * address for __ip_route_output_key() is set to zero, so __ip_route_output_key
* thinks we're handling a locally generated packet and won't care * thinks we're handling a locally generated packet and won't care
* if IP forwarding is allowed. We send a warning message to the users's * if IP forwarding is allowed. We send a warning message to the users's
* log telling her to put IP forwarding on. * log telling her to put IP forwarding on.
...@@ -158,8 +159,11 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb) ...@@ -158,8 +159,11 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb)
if (ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, if (ip_route_input(skb, iph->daddr, iph->saddr, iph->tos,
dev)) { dev)) {
struct rtable *rt; struct rtable *rt;
struct flowi fl = { .nl_u =
{ .ip4_u = { .daddr = iph->daddr, .saddr = 0 ,
.tos = iph->tos} }, .proto = 0};
if (!ip_route_output(&rt, iph->daddr, 0, iph->tos, 0)) { if (!ip_route_output_key(&rt, &fl)) {
/* Bridged-and-DNAT'ed traffic doesn't /* Bridged-and-DNAT'ed traffic doesn't
* require ip_forwarding. * require ip_forwarding.
*/ */
......
...@@ -17,6 +17,7 @@ obj-$(CONFIG_NET) += dev.o dev_mcast.o dst.o neighbour.o rtnetlink.o utils.o ...@@ -17,6 +17,7 @@ obj-$(CONFIG_NET) += dev.o dev_mcast.o dst.o neighbour.o rtnetlink.o utils.o
obj-$(CONFIG_NETFILTER) += netfilter.o obj-$(CONFIG_NETFILTER) += netfilter.o
obj-$(CONFIG_NET_DIVERT) += dv.o obj-$(CONFIG_NET_DIVERT) += dv.o
obj-$(CONFIG_NET_PROFILE) += profile.o obj-$(CONFIG_NET_PROFILE) += profile.o
obj-$(CONFIG_NET_PKTGEN) += pktgen.o
obj-$(CONFIG_NET_RADIO) += wireless.o obj-$(CONFIG_NET_RADIO) += wireless.o
# Ugly. I wish all wireless drivers were moved in drivers/net/wireless # Ugly. I wish all wireless drivers were moved in drivers/net/wireless
obj-$(CONFIG_NET_PCMCIA_RADIO) += wireless.o obj-$(CONFIG_NET_PCMCIA_RADIO) += wireless.o
......
This diff is collapsed.
...@@ -1026,7 +1026,8 @@ static int fib_seq_show(struct seq_file *seq, void *v) ...@@ -1026,7 +1026,8 @@ static int fib_seq_show(struct seq_file *seq, void *v)
"%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u", "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u",
fi->fib_dev ? fi->fib_dev->name : "*", prefix, fi->fib_dev ? fi->fib_dev->name : "*", prefix,
fi->fib_nh->nh_gw, flags, 0, 0, fi->fib_priority, fi->fib_nh->nh_gw, flags, 0, 0, fi->fib_priority,
mask, fi->fib_advmss + 40, fi->fib_window, mask, (fi->fib_advmss ? fi->fib_advmss + 40 : 0),
fi->fib_window,
fi->fib_rtt >> 3); fi->fib_rtt >> 3);
else else
snprintf(bf, sizeof(bf), snprintf(bf, sizeof(bf),
......
...@@ -523,11 +523,11 @@ void ipgre_err(struct sk_buff *skb, u32 info) ...@@ -523,11 +523,11 @@ void ipgre_err(struct sk_buff *skb, u32 info)
/* change mtu on this route */ /* change mtu on this route */
if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) { if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) {
if (rel_info > skb2->dst->pmtu) { if (rel_info > dst_pmtu(skb2->dst)) {
kfree_skb(skb2); kfree_skb(skb2);
return; return;
} }
skb2->dst->pmtu = rel_info; skb2->dst->ops->update_pmtu(skb2->dst, rel_info);
rel_info = htonl(rel_info); rel_info = htonl(rel_info);
} else if (type == ICMP_TIME_EXCEEDED) { } else if (type == ICMP_TIME_EXCEEDED) {
struct ip_tunnel *t = (struct ip_tunnel*)skb2->dev->priv; struct ip_tunnel *t = (struct ip_tunnel*)skb2->dev->priv;
......
...@@ -452,11 +452,11 @@ void ipip_err(struct sk_buff *skb, u32 info) ...@@ -452,11 +452,11 @@ void ipip_err(struct sk_buff *skb, u32 info)
/* change mtu on this route */ /* change mtu on this route */
if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) { if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) {
if (rel_info > skb2->dst->pmtu) { if (rel_info > dst_pmtu(skb2->dst)) {
kfree_skb(skb2); kfree_skb(skb2);
return; return;
} }
skb2->dst->pmtu = rel_info; skb2->dst->ops->update_pmtu(skb2->dst, rel_info);
rel_info = htonl(rel_info); rel_info = htonl(rel_info);
} else if (type == ICMP_TIME_EXCEEDED) { } else if (type == ICMP_TIME_EXCEEDED) {
struct ip_tunnel *t = (struct ip_tunnel*)skb2->dev->priv; struct ip_tunnel *t = (struct ip_tunnel*)skb2->dev->priv;
......
...@@ -1111,7 +1111,7 @@ static inline int ipmr_forward_finish(struct sk_buff *skb) ...@@ -1111,7 +1111,7 @@ static inline int ipmr_forward_finish(struct sk_buff *skb)
{ {
struct dst_entry *dst = skb->dst; struct dst_entry *dst = skb->dst;
if (skb->len <= dst->pmtu) if (skb->len <= dst_pmtu(dst))
return dst->output(skb); return dst->output(skb);
else else
return ip_fragment(skb, dst->output); return ip_fragment(skb, dst->output);
...@@ -1167,7 +1167,7 @@ static void ipmr_queue_xmit(struct sk_buff *skb, struct mfc_cache *c, ...@@ -1167,7 +1167,7 @@ static void ipmr_queue_xmit(struct sk_buff *skb, struct mfc_cache *c,
dev = rt->u.dst.dev; dev = rt->u.dst.dev;
if (skb->len+encap > rt->u.dst.pmtu && (ntohs(iph->frag_off) & IP_DF)) { if (skb->len+encap > dst_pmtu(&rt->u.dst) && (ntohs(iph->frag_off) & IP_DF)) {
/* Do not fragment multicasts. Alas, IPv4 does not /* Do not fragment multicasts. Alas, IPv4 does not
allow to send ICMP, so that packets will disappear allow to send ICMP, so that packets will disappear
to blackhole. to blackhole.
......
...@@ -85,14 +85,14 @@ ipt_tcpmss_target(struct sk_buff **pskb, ...@@ -85,14 +85,14 @@ ipt_tcpmss_target(struct sk_buff **pskb,
return NF_DROP; /* or IPT_CONTINUE ?? */ return NF_DROP; /* or IPT_CONTINUE ?? */
} }
if((*pskb)->dst->pmtu <= (sizeof(struct iphdr) + sizeof(struct tcphdr))) { if(dst_pmtu((*pskb)->dst) <= (sizeof(struct iphdr) + sizeof(struct tcphdr))) {
if (net_ratelimit()) if (net_ratelimit())
printk(KERN_ERR printk(KERN_ERR
"ipt_tcpmss_target: unknown or invalid path-MTU (%d)\n", (*pskb)->dst->pmtu); "ipt_tcpmss_target: unknown or invalid path-MTU (%d)\n", dst_pmtu((*pskb)->dst));
return NF_DROP; /* or IPT_CONTINUE ?? */ return NF_DROP; /* or IPT_CONTINUE ?? */
} }
newmss = (*pskb)->dst->pmtu - sizeof(struct iphdr) - sizeof(struct tcphdr); newmss = dst_pmtu((*pskb)->dst->pmtu) - sizeof(struct iphdr) - sizeof(struct tcphdr);
} else } else
newmss = tcpmssinfo->mss; newmss = tcpmssinfo->mss;
......
...@@ -38,8 +38,8 @@ match(const struct sk_buff *skb, ...@@ -38,8 +38,8 @@ match(const struct sk_buff *skb,
& ((const unsigned long *)info->in_mask)[i]; & ((const unsigned long *)info->in_mask)[i];
} }
if ((ret != 0) ^ !(info->invert & IPT_PHYSDEV_OP_MATCH_IN)) if ((ret == 0) ^ !(info->invert & IPT_PHYSDEV_OP_MATCH_IN))
return 1; return 0;
for (i = 0, ret = 0; i < IFNAMSIZ/sizeof(unsigned long); i++) { for (i = 0, ret = 0; i < IFNAMSIZ/sizeof(unsigned long); i++) {
ret |= (((const unsigned long *)outdev)[i] ret |= (((const unsigned long *)outdev)[i]
......
...@@ -1432,8 +1432,7 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd, ...@@ -1432,8 +1432,7 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
switch(cmd) switch(cmd) {
{
case SIOCOUTQ: case SIOCOUTQ:
{ {
int amount = atomic_read(&sk->wmem_alloc); int amount = atomic_read(&sk->wmem_alloc);
...@@ -1452,35 +1451,12 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd, ...@@ -1452,35 +1451,12 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
return put_user(amount, (int *)arg); return put_user(amount, (int *)arg);
} }
case SIOCGSTAMP: case SIOCGSTAMP:
if(sk->stamp.tv_sec==0) if (sk->stamp.tv_sec==0)
return -ENOENT; return -ENOENT;
if (copy_to_user((void *)arg, &sk->stamp, if (copy_to_user((void *)arg, &sk->stamp,
sizeof(struct timeval))) sizeof(struct timeval)))
return -EFAULT; return -EFAULT;
break; break;
case SIOCGIFFLAGS:
#ifndef CONFIG_INET
case SIOCSIFFLAGS:
#endif
case SIOCGIFCONF:
case SIOCGIFMETRIC:
case SIOCSIFMETRIC:
case SIOCGIFMEM:
case SIOCSIFMEM:
case SIOCGIFMTU:
case SIOCSIFMTU:
case SIOCSIFLINK:
case SIOCGIFHWADDR:
case SIOCSIFHWADDR:
case SIOCSIFMAP:
case SIOCGIFMAP:
case SIOCSIFSLAVE:
case SIOCGIFSLAVE:
case SIOCGIFINDEX:
case SIOCGIFNAME:
case SIOCGIFCOUNT:
case SIOCSIFHWBROADCAST:
return(dev_ioctl(cmd,(void *) arg));
#ifdef CONFIG_INET #ifdef CONFIG_INET
case SIOCADDRT: case SIOCADDRT:
...@@ -1501,7 +1477,7 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd, ...@@ -1501,7 +1477,7 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
#endif #endif
default: default:
return -EOPNOTSUPP; return dev_ioctl(cmd, (void *)arg);
} }
return 0; return 0;
} }
......
...@@ -1922,30 +1922,6 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar ...@@ -1922,30 +1922,6 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar
sock->file->f_flags |= O_NONBLOCK; sock->file->f_flags |= O_NONBLOCK;
return 0; return 0;
case SIOCGIFFLAGS:
#ifndef CONFIG_INET
case SIOCSIFFLAGS:
#endif
case SIOCGIFCONF:
case SIOCGIFMETRIC:
case SIOCSIFMETRIC:
case SIOCGIFMEM:
case SIOCSIFMEM:
case SIOCGIFMTU:
case SIOCSIFMTU:
case SIOCSIFLINK:
case SIOCGIFHWADDR:
case SIOCSIFHWADDR:
case SIOCSIFMAP:
case SIOCGIFMAP:
case SIOCSIFSLAVE:
case SIOCGIFSLAVE:
case SIOCGIFINDEX:
case SIOCGIFNAME:
case SIOCGIFCOUNT:
case SIOCSIFHWBROADCAST:
return(dev_ioctl(cmd,(void *) arg));
#ifdef CONFIG_INET #ifdef CONFIG_INET
case SIOCADDRT: case SIOCADDRT:
case SIOCDELRT: case SIOCDELRT:
...@@ -1968,7 +1944,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar ...@@ -1968,7 +1944,7 @@ static int wanpipe_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar
#endif #endif
default: default:
return -EOPNOTSUPP; return dev_ioctl(cmd,(void *) arg);
} }
/*NOTREACHED*/ /*NOTREACHED*/
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment