Age | Commit message (Collapse) | Author | Files | Lines |
|
Found with the "codespell" utility
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
We enabled additional compiler warnings in commit 26d8ba170355c9, but
so far we did not address the additional warnings in the js2x code
yet. This patch fixes at least some of the trivial warnings there.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
Since libnet is now linked to Paflof directly, we do not have to
link it into net-snk anymore. So for board-qemu, we can now even
exclude net-snk completely from the build (for board-js2x, it is
still required for the biosemu, so we can not erase the net-snk
folder completely yet).
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
Now that we link libnet to Paflof, we can call the ping
function there directly instead of using the one from
net-snk. We add a similar Forth-to-C wrapper like it has
already been done for netboot() - simplification and clean-up
will be done in a later patch once we do not link against
net-snk anymore.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
Now that all necessary functions are provided by Paflof, too,
we can finally link the libnet code to this binary. To be able
to call the netboot() function from the Forth code now, we also
add a wrapper that takes the parameter string from the obp-tftp
package and converts it to an argv array that is expected by
the netboot() function.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
Code is slightly based on the implementation from net-snk, but
has been adapted to use the forth_eval() and forth_push/pop() macros
instead.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
These files should go into libnet, too, so we can later link
them to paflof instead of net-snk.
Note: A "make distclean" is required after applying this patch
to make sure that the dependencies for the moved files are
properly re-generated.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
When we want to link the network stack to other parts of the
firmware later (paflof), we've got to turn it into a proper
library first.
Note: Make sure to run "make distclean" after this patch, so that
the dependencies for the moved files get rebuilt properly.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
These prefixes prevent that the files can easily be moved to another
folder, so let's use proper "-I" statements in the Makefiles instead.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
The whole ethernet frame can be up to 1518 bytes including the ethernet
header. So this value should be used instead of 1500 when the whole
ethernet packet is affected. Since we've already got a nice define
for this value, use ETH_MTU_SIZE where it is appropriate.
This patch also removes a "memset(n->eth_frame, 0, 1500)" in send_ipv6()
to get rid of the magic value 1500 there -- it can be removed since
the whole ethernet packet is filled into the buffer right after the
memset, so there are no gaps that should be cleared first.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
When ip6addr_add() is called for the first time, both the first_ip6
and the last_ip6 pointer are not initialized yet, i.e. contain NULL.
So writing to "last_ip6->next" is a bad idea here. Fix it so that
this value is only written when the function is not called for the
first time.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
The set_ipv6_address() function calls ip6_create_ll_address() to
get a link-local address. The latter function uses malloc to create
a buffer for composing that address, and returns the corresponding
poniter to the caller. However, set_ipv6_address() does not free
that buffer again, so the allocated memory is lost.
Since set_ipv6_address() already allocated space for the new IPv6
address anyway, let's fix this issue by passing the buffer from
set_ipv6_address() to ip6_create_ll_address() instead, so that
ip6_create_ll_address() does not have to allocate memory at all.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
The IPv6 code uses malloc in a couple of places to allocate the memory
for a struct. But it does not properly initializes all members of the
struct after the allocation, so the uninitialized members might contain
random data. So we should better clear the whole memory for those
structs to make sure we do not run into some hard-to-reproduce random
problems later.
Reported-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
The "struct neighbor *n" pointer in send_ipv6() can be NULL, e.g.
when we're sending to multicast addresses or to a server that sits
behind a router (since we do not have an entry in the neighbor cache
in this case).
However, the final code in send_ipv6() is always using n->eth_frame
to assemble the ethernet packet, and thus silently writes the data
into the low memory (which happens unnoticed because SLOF does not
use the MMU for memory protection).
This issue is now fixed by using a separate buffer for assembling
those ethernet packets instead. The block for using the router's
MAC address is also moved out of the block that is supposed to handle
the unicast transfers, so that we do not accidentially end up in the
neighbour solicitation code here (which also relies on n != NULL).
Reported-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
ping was failing for machine across the subnet with statically assinged
IP address. The parsed gateway address was ignored in the stack because
the router variable was not set.
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
The current ping command does not take netmask as argument, updated the
ping command to take "client-ip/nn" format ip address.
Add routine to return netmask(class based), when not provided by user.
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
The old netflash code is not available in the net-snk anymore,
so it does not make sense to keep the Forth wrapper around.
Anyway, "update-flash -f net:..." can be used nowadays instead.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
Some parts of the IPv6 code are still indented with spaces. Let's
use tabs instead as mandated by the SLOF coding conventions.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
The send_ipv6() function should return after doing NDP, since either
the queued packet got send out during handle_na() already, or it has
been stored to be sent out later (once the neighbor advertisment has
been received). If we don't return here, the code runs into the final
send_ether() here later, which then sends out the packet a second time.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
The code in send_ipv6() currently basically looks like this:
uint8_t *mac_addr, mac[6];
mac_addr = mac;
...
n = find_neighbor (&ip_dst);
if (ip6_is_multicast (&ip_dst)) {
mac_addr = ip6_to_multicast_mac (&ip_dst, mac);
}
else {
// Check if the MAC address is already cached
if (n) {
if (memcmp(n->mac, null_mac, ETH_ALEN) != 0)
memcpy (mac_addr, &(n->mac), ETH_ALEN);
/* XXX */
}
...
}
...
fill_ethhdr (n->eth_frame, htons(ETHERTYPE_IPv6), get_mac_address(),
mac_addr);
That means mac_addr initially points to the uninitialized mac[6]
array on the stack. Now if there was already an entry in the neighbor
cache, but the MAC address has not been determined yet, that
uninitialized array could be used as final MAC address for fill_ethhdr()
(since there is no "else" path at the spot marked with XXX above),
resulting in random data in the MAC address field of the ethernet packet.
Let's fix this issue by letting mac_addr point to the null_mac by
default instead, so that it never points to invalid data. Also
rename mac[6] to mc_mac[6] to make it clear that this array is
only used for storing the multicast mac address.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
The network boot over IPv6 currently fails if the TFTP server
is not in the same subnet as the SLOF client. In that case we
have to fill in the MAC address of a router into our packets
to get them to the right place.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
With the removal of dupicate strtoip in patch "dhcp: Remove duplicated
strtoip()" (commit 896e31da2cc260bf5311a89b63683def20329c5b), we get
following warnings messages:
dhcp.c: In function ‘dhcpv4’:
dhcp.c:215:16: warning: pointer targets in passing argument 1 of ‘strtoip’ differ in signedness [-Wpointer-sign]
if (!strtoip(dhcp_tftp_name, (uint8_t *)&dhcp_tftp_ip)) {
^
In file included from dhcp.c:51:0:
../netapps/args.h:20:5: note: expected ‘const char *’ but argument is of type ‘int8_t * {aka signed char *}’
int strtoip(const char *, char[4]);
^
dhcp.c:215:32: warning: pointer targets in passing argument 2 of ‘strtoip’ differ in signedness [-Wpointer-sign]
if (!strtoip(dhcp_tftp_name, (uint8_t *)&dhcp_tftp_ip)) {
^
In file included from dhcp.c:51:0:
../netapps/args.h:20:5: note: expected ‘char *’ but argument is of type ‘uint8_t * {aka unsigned char *}’
int strtoip(const char *, char[4]);
^
There were unnecessary typecasts which could be removed by declaring
dhcp_tftp_name and dhcp_filename. Along with this, change the dns_get_ip
signature as well to reduce typecast.
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
There is another implementation in netapps/args.c which is used by
netboot.c and ping.c so switch to it.
Suggested-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Thomas Huth <thuth@redhat.com>
|
|
This fixes gcc warnings but unlike other places, this does not change
the type of bytes_received as recv() may return a negative value;
instead this adds:
1) casting to size_t when comparing the size;
2) an additional check for a negative value returned from recv().
The make command used to test:
make qemu WARNFLAGS=-Wextra
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Thomas Huth <thuth@redhat.com>
|
|
This replaces some local variable types and some function parameters from
signed to unsigned to fix gcc warnings.
Tested DHCP+TFTP on both IPv4 and IPv6.
The make command used to test:
make qemu WARNFLAGS=-Wextra
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Thomas Huth <thuth@redhat.com>
|
|
This restyles function prototypes:
- return types on the same line;
- opening brace is on the next line.
VIM configs used for this was:
set noexpandtab
set tabstop=8
set shiftwidth=4
set cino=:0,(0
This replaces [><]* with "*" as >< are also used to resolve merge
conflicts.
This removes trailing spaces.
This removes some redundant braces.
This should cause no behavioural change.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Thomas Huth <thuth@redhat.com>
|
|
The dhcp6_process_options() function allocates a struct
dhcp6_received_options each time it is called - but that
struct never gets used - and especially is also never freed
again. Fix this memory leak by simply removing the unused code.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
ip6_to_multicast_mac() uses a malloc to allocate a 6 bytes buffer
for the MAC address - which never gets freed again! That means
we're leaking memory for every multicast IPv6 packet that gets
send out. Fix it by simply using the "uint8_t mac[6]" array from
send_ipv6() instead.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
The code that checks for NEIGHBOUR_SOLICITATION packets is bad
in two ways: First, it does not check that the packet is really
an ICMPv6 packet, so it could accidentially be triggered for UDP
or TCP packets, too. Second, the fill_ethhdr() is redundant (since
it is done at the end of the function again) and also wrong (it
uses the wrong buffer pointer to fill in the ethernet header).
All we really need here is to get the right MAC address via
ip6_to_multicast_mac() - and this is handled in the following
if-statement already (NEIGHBOUR_SOLICITATIONs are always sent
as multicast in the send_neighbour_solicitation() function), so
the bad code block can simply be removed to fix the two issues.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
When manually specifying the TFTP server address and boot file name
in IPv6 mode, we can still get the client IPv6 address via link-local
or stateless IPv6 address autoconfiguration. So the netboot should
not abort if just the client IPv6 address has not been specified yet.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
Using a memcpy to just compare one byte looks very cumbersome.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
The IPv6 code declares a bunch of global variables (without "extern"
keyword!) in the ipv6.h header file. This is bad style and does not
work when linking with "-fno-common" for example. So let's move
the variables to the files where they are used instead.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
When the IPv6 code is told to create IPv6 addresses automatically
(by passing NULL as parameter to set_ipv6_address()), the netboot
code currently only uses link-local IPv6 addresses - which is bad
since they can not be routed, e.g. if the TFTP server is not on
the same link.
So set_ipv6_address(NULL) should set own_ip6 preferably to a non-local
unicast address if it has been generated successfully during ipv6_init().
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
The code that checks whether the router advertisments contain only
a link-local address has a bug: It must check the full first 10 bits
of the address, not only the first 9 bits. Otherwise, site-local
addresses (which start with 0xFEC0...) are also recognized as
link-local, which is wrong, of course.
Fix it by also introducing a proper wrapper functions for link-local
addresses (which will be used in a later patch, too).
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
While looking at the network traffic from SLOF with Wireshark, I
noticed that there are some junk bytes at the end of TFTP ACK
packets. The problem is that send_ack() adds sizeof(struct ethhdr)
to the length of the packet that it wants to transmit. But adding
the sizeof(struct ethhdr) to the length of the packet is done
within send_ipv6() already, so this value got added twice.
Removing it from send_ack() fixes this issue - the packets then
look fine in Wireshark again.
send_error() apparently suffers from the same issue, so let's
also remove the sizeof(struct ethhdr) from that function.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
Wireshark reports bad FCS values and trailing zeros for SLOF's
DHCPv6 packets. This happens due to two bugs. First, the length
given to send_ipv6() contained sizeof(struct ethhdr) - but
adding that length is the responsibility of the send_ipv6()
function itself, the upper layers must not add this length yet.
Second, struct option_request was defined with 5 options, but
the code only uses 3 options instead. So when the code uses
sizeof(struct dhcp_message_header) (which contains the struct
option_request), there were additional unused bytes appended
to the message.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
Generate a proper transaction ID before sending DHCPv4 packets
and check whether the DHCPv4 replies contain that correct XID, too.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
Generate a proper transaction ID before sending DHCPv6 packets
and check whether the DHCPv6 replies contain that correct XID, too.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
Use the MAC address and the current timebase value to seed the
pseudo-random number generator - this will hopefully give use
enough pseudo-randomness so that two guests that are booting in
parallel won't use the same rand() numbers.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
The output of net-snk is bad in a couple of places:
1) The hard-coded "Bootloader 1.6" message is pretty useless
for the users (we never changed the version number in the
past five years) - so let's change that into printing
"Initializing NIC" instead.
2) "Requesting IP address via DHCP" is wrong for DHCPv6 since
in this case, the net-snk might only request the boot file
name via DHCPv6. In the IPv6-only case, the net-snk was
already printing "Requesting information..." instead, so
let's unify these texts to always print "information" instead
of "IP address"
3) The client IPv6 address is never printed out, so do that now,
too.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
The pending_pkt structure is not really an ARP cache entry, and
the fields .ipv4_addr, .mac_addr and .pkt_pending were only set
but never read again. So to avoid confusion, convert the pending
packet structure into a simple array for storing the packet and
an additional length variable.
Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
pending_pkt.pkt_pending is never read, thus setting it to 0
in handle_arp() does not make much sense. On the other hand,
arp_table[i].pkt_pending is never set back to 0, but it is
checked for tracking which packets still have to be sent
in handle_arp(), thus we might send out the same queued packet
multiple times when receiving more than one ARP packet from the
other side.
So setting "pending_pkt.pkt_pending = 0" seems to be a typo, and
"arp_table[i].pkt_pending = 0" should be right instead.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
The recent binutils version introduces explicit definition of
a TOC symbol which points to the .toc section and enforces .toc
alignment to 256 rather than 8 bytes before.
For now the TOC symbol points to same location as it was before -
start of .toc + 0x8000; however as this might change, we should not
rely on that in the source code.
This changes __toc_start (for qemu and js2x boards), _got (for net-snk,
takeover, rtas) in linker scripts to use explicitely defined TOC if
defined and fall back to the older scheme if not.
This changes r2 (the register pointing to TOC) setup code not to add
0x8000 as linker scripts do that now.
Here is a bit more information about the change:
https://sourceware.org/ml/binutils/2015-10/msg00124.html
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=a27e685fa0a6480bdb07e3be359558524cec89b7
Tested on
1. gcc version 4.8.3 20140911 (Red Hat 4.8.3-7) (GCC)
GNU ld version 2.23.2
2. gcc version 5.2.1 20151001 (GCC)
GNU ld (GNU Binutils) 2.25.51.20150930
Reported-by: William Grant <wgrant@ubuntu.com>
Tested-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
The ioctl.h header has been removed with commit 6495aef5b625b9ddae
("net-snk: Remove module system"), so it can not be included in
the takeover client anymore. Thus remove the include statement (which
is no problem since the takeover client does not use ioctls anyway).
Include unistd.h instead, to avoid that the compiler is printing
out a warning about a missing prototype of the function sbrk().
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
Fixed the compiler warnings about wrong and missing prototypes in the
biosemu snk code.
Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
|
|
The send packet code does understand that the IP is not part of the
current network and needs to use the router. And then tries to get the
MAC address of the router IP from arp cache, that fails. This is
becuase there was no ARP Request send for the router IP.
So in case when there is router involved, send arp request for the
router IP and after the reply, we have the router mac cached to
communicate with.
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
|
|
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
|
|
In favor of the libc one
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
|
|
No need to have a single giant section, break it back up, add
some missing bits, and make sure .opd is separate so that objdump
and gdb can properly reconstitute the dot symbols.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[ do not discard .comment, this is fixed with binutils 2.24]
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
|
|
Now that we are using the libc stdio
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
|