[U-Boot] [PATCH] - add dns
Robin Getz
rgetz at blackfin.uclinux.org
Mon Jul 20 01:30:43 CEST 2009
On Sat 18 Jul 2009 21:15, Mike Frysinger pondered:
> On Saturday 18 July 2009 20:27:00 Robin Getz wrote:
> > On Sat 18 Jul 2009 18:11, Mike Frysinger pondered:
> > > keep the modulus something with only 1 bit set so gcc will optimize into
> > > a simple and operation. probably add a comment about it too:
> > > /* make src port a little random, but use something trivial to compute
> > > */
> >
> > OK - So, this would give three different variations:
> >
So, these are definitality ugly...
> > net/tftp.c: TftpOurPort = 1024 + (get_timer(0) % 3072);
00000000 <_random_port>:
0: 78 05 [--SP] = (R7:7);
2: 67 01 [--SP] = RETS;
4: a6 6f SP += -0xc; /* (-12) */
6: 00 60 R0 = 0x0 (X); /* R0=0x0( 0) */
8: ff e3 fc ff CALL 0x0 <_random_port>;
a: R_BFIN_PCREL24 _get_timer
c: 41 e1 aa aa R1.H = 0xaaaa; /* (-21846) R1=0xaaaa000c(-1431699444) */
10: 01 e1 ab aa R1.L = 0xaaab; /* (-21845) R1=0xaaaaaaab(-1431655765) */
14: 38 30 R7 = R0;
16: ff e3 f5 ff CALL 0x0 <_random_port>;
18: R_BFIN_PCREL24 ___umulsi3_highpart
1a: 58 4e R0 >>= 0xb;
1c: 21 e1 00 0c R1 = 0xc00 (X); /* R1=0xc00(3072) */
20: c8 40 R0 *= R1;
22: 66 6c SP += 0xc; /* ( 12) */
24: c7 53 R7 = R7 - R0;
26: 20 e1 00 04 R0 = 0x400 (X); /* R0=0x400(1024) */
2a: c7 51 R7 = R7 + R0;
2c: 27 01 RETS = [SP++];
2e: 07 30 R0 = R7;
30: 38 05 (R7:7) = [SP++];
32: 10 00 RTS;
Disassembly of section .text.NetSetTimeout:
> > net/nfs.c: NfsOurPort = 4096 + (get_ticks() % 3072);
00000000 <_random_port>:
0: 67 01 [--SP] = RETS;
2: 86 6f SP += -0x10; /* (-16) */
4: ff e3 fe ff CALL 0x0 <_random_port>;
6: R_BFIN_PCREL24 _get_ticks
8: 02 60 R2 = 0x0 (X); /* R2=0x0( 0) */
a: f2 b0 [SP + 0xc] = R2;
c: 22 e1 00 0c R2 = 0xc00 (X); /* R2=0xc00(3072) */
10: ff e3 f8 ff CALL 0x0 <_random_port>;
12: R_BFIN_PCREL24 ___umoddi3
14: 86 6c SP += 0x10; /* ( 16) */
16: 08 30 R1 = R0;
18: 27 01 RETS = [SP++];
1a: 20 e1 00 10 R0 = 0x1000 (X); /* R0=0x1000(4096) */
1e: 01 50 R0 = R1 + R0;
20: 10 00 RTS;
> > net/sntp.c: SntpOurPort = 10000 + (get_timer(0) % 4096);
00000000 <_random_port>:
0: 67 01 [--SP] = RETS;
2: a6 6f SP += -0xc; /* (-12) */
4: 00 60 R0 = 0x0 (X); /* R0=0x0( 0) */
6: ff e3 fd ff CALL 0x0 <_random_port>;
8: R_BFIN_PCREL24 _get_timer
a: 21 e1 ff 0f R1 = 0xfff (X); /* R1=0xfff(4095) */
e: 66 6c SP += 0xc; /* ( 12) */
10: 08 54 R0 = R0 & R1;
12: 27 01 RETS = [SP++];
14: 21 e1 10 27 R1 = 0x2710 (X); /* R1=0x2710(10000) */
18: 08 50 R0 = R0 + R1;
1a: 10 00 RTS;
Disassembly of section .text.NetSetTimeout:
> 1024 + (get_timer(0) % 0x8000);
00000000 <_random_port>:
0: 67 01 [--SP] = RETS;
2: a6 6f SP += -0xc; /* (-12) */
4: 00 60 R0 = 0x0 (X); /* R0=0x0( 0) */
6: ff e3 fd ff CALL 0x0 <_random_port>;
8: R_BFIN_PCREL24 _get_timer
a: 21 e1 ff 7f R1 = 0x7fff (X); /* R1=0x7fff(32767) */
e: 66 6c SP += 0xc; /* ( 12) */
10: 08 54 R0 = R0 & R1;
12: 27 01 RETS = [SP++];
14: 21 e1 00 04 R1 = 0x400 (X); /* R1=0x400(1024) */
18: 08 50 R0 = R0 + R1;
1a: 10 00 RTS;
Disassembly of section .text.NetSetTimeout:
> > Does it make sense to have 4 different ones? (not to me)...
> >
> > Or something new & common in ./net.c:random_port()
>
> i would make a new patch that adds a new random_port() function and converts
> existing consumers to that, and then have the dns code rely on that.
>
> and you should adopt my implementation because the generated code is
> much much nicer than the others ;)
At least on Blackfin - the sntp version and yours are computationally
equal - although I think yours ends up being more random - so yeah, I'll
use that one.
> a quick google shows:
> - sntp - any non-zero source port is OK
> - tftp - "between 0 and 65535"
> - nfs - couldnt find anything, but i'm pretty sure there isnt one
>
> get_ticks() and get_timer(0) are pretty much equivalent
Sounds great.
More information about the U-Boot
mailing list