From owner-svn-src-user@FreeBSD.ORG Tue Jan 15 00:39:16 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 41C0FBBB; Tue, 15 Jan 2013 00:39:16 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 32D62846; Tue, 15 Jan 2013 00:39:16 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0F0dGte094205; Tue, 15 Jan 2013 00:39:16 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0F0dFuv094202; Tue, 15 Jan 2013 00:39:15 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201301150039.r0F0dFuv094202@svn.freebsd.org> From: Sean Bruno Date: Tue, 15 Jan 2013 00:39:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245442 - in user/sbruno/pxe_http: . acpi_sony btx_mod btx_mod/btx btx_mod/btxldr btx_mod/lib devd2dbus i386_mod libi386_mod libstand_mod loader_mod ptelnet X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jan 2013 00:39:16 -0000 Author: sbruno Date: Tue Jan 15 00:39:15 2013 New Revision: 245442 URL: http://svnweb.freebsd.org/changeset/base/245442 Log: Capture SOC project pxe_http at p4 r150388 Added: user/sbruno/pxe_http/ user/sbruno/pxe_http/Makefile user/sbruno/pxe_http/README user/sbruno/pxe_http/acpi_sony/ user/sbruno/pxe_http/acpi_sony/acpi_sony.c user/sbruno/pxe_http/acpi_sony/acpi_sony.h user/sbruno/pxe_http/btx_mod/ user/sbruno/pxe_http/btx_mod/Makefile user/sbruno/pxe_http/btx_mod/Makefile.inc user/sbruno/pxe_http/btx_mod/btx/ user/sbruno/pxe_http/btx_mod/btx/Makefile user/sbruno/pxe_http/btx_mod/btx/btx.S user/sbruno/pxe_http/btx_mod/btxcsu.s user/sbruno/pxe_http/btx_mod/btxldr/ user/sbruno/pxe_http/btx_mod/btxldr/Makefile user/sbruno/pxe_http/btx_mod/btxldr/btxldr.S user/sbruno/pxe_http/btx_mod/btxsys.s user/sbruno/pxe_http/btx_mod/btxv86.h user/sbruno/pxe_http/btx_mod/btxv86.s user/sbruno/pxe_http/btx_mod/lib/ user/sbruno/pxe_http/btx_mod/lib/Makefile user/sbruno/pxe_http/btx_mod/lib/btxcsu.s user/sbruno/pxe_http/btx_mod/lib/btxsys.s user/sbruno/pxe_http/btx_mod/lib/btxv86.h user/sbruno/pxe_http/btx_mod/lib/btxv86.s user/sbruno/pxe_http/devd2dbus/ user/sbruno/pxe_http/devd2dbus/bsdbus.c user/sbruno/pxe_http/devd2dbus/bsdbus.h user/sbruno/pxe_http/httpfs.c user/sbruno/pxe_http/httpfs.h user/sbruno/pxe_http/i386_mod/ user/sbruno/pxe_http/i386_mod/Makefile user/sbruno/pxe_http/libi386_mod/ user/sbruno/pxe_http/libi386_mod/Makefile user/sbruno/pxe_http/libi386_mod/pxe.c user/sbruno/pxe_http/libi386_mod/pxe.h user/sbruno/pxe_http/libstand_mod/ user/sbruno/pxe_http/libstand_mod/printf.c user/sbruno/pxe_http/libstand_mod/stand.h user/sbruno/pxe_http/loader_mod/ user/sbruno/pxe_http/loader_mod/Makefile user/sbruno/pxe_http/loader_mod/conf.c user/sbruno/pxe_http/loader_mod/help.i386 user/sbruno/pxe_http/loader_mod/loader.rc user/sbruno/pxe_http/loader_mod/main.c user/sbruno/pxe_http/loader_mod/version user/sbruno/pxe_http/ptelnet/ user/sbruno/pxe_http/ptelnet/README user/sbruno/pxe_http/ptelnet/options.c user/sbruno/pxe_http/ptelnet/pxe_telnet.c user/sbruno/pxe_http/ptelnet/pxe_telnet.h user/sbruno/pxe_http/ptelnet/telnet_fsm.c user/sbruno/pxe_http/ptelnet/telnet_fsm.h user/sbruno/pxe_http/pxe_arp.c user/sbruno/pxe_http/pxe_arp.h user/sbruno/pxe_http/pxe_await.c user/sbruno/pxe_http/pxe_await.h user/sbruno/pxe_http/pxe_buffer.c user/sbruno/pxe_http/pxe_buffer.h user/sbruno/pxe_http/pxe_connection.c user/sbruno/pxe_http/pxe_connection.h user/sbruno/pxe_http/pxe_core.c user/sbruno/pxe_http/pxe_core.h user/sbruno/pxe_http/pxe_dhcp.c user/sbruno/pxe_http/pxe_dhcp.h user/sbruno/pxe_http/pxe_dns.c user/sbruno/pxe_http/pxe_dns.h user/sbruno/pxe_http/pxe_filter.c user/sbruno/pxe_http/pxe_filter.h user/sbruno/pxe_http/pxe_http.c user/sbruno/pxe_http/pxe_http.h user/sbruno/pxe_http/pxe_httpls.c user/sbruno/pxe_http/pxe_httpls.h user/sbruno/pxe_http/pxe_icmp.c user/sbruno/pxe_http/pxe_icmp.h user/sbruno/pxe_http/pxe_ip.c user/sbruno/pxe_http/pxe_ip.h user/sbruno/pxe_http/pxe_ip6.h user/sbruno/pxe_http/pxe_isr.S user/sbruno/pxe_http/pxe_isr.h user/sbruno/pxe_http/pxe_mem.c user/sbruno/pxe_http/pxe_mem.h user/sbruno/pxe_http/pxe_segment.c user/sbruno/pxe_http/pxe_segment.h user/sbruno/pxe_http/pxe_sock.c user/sbruno/pxe_http/pxe_sock.h user/sbruno/pxe_http/pxe_tcp.c user/sbruno/pxe_http/pxe_tcp.h user/sbruno/pxe_http/pxe_udp.c user/sbruno/pxe_http/pxe_udp.h user/sbruno/pxe_http/socketfs.c user/sbruno/pxe_http/socketfs.h Added: user/sbruno/pxe_http/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/sbruno/pxe_http/Makefile Tue Jan 15 00:39:15 2013 (r245442) @@ -0,0 +1,50 @@ +# pxe_http project +# +LIB= pxe_http +INTERNALLIB= + +SRCS= pxe_isr.S pxe_mem.c pxe_buffer.c pxe_await.c pxe_arp.c pxe_ip.c \ + pxe_core.c pxe_icmp.c pxe_udp.c pxe_filter.c pxe_dns.c \ + pxe_dhcp.c pxe_segment.c pxe_tcp.c pxe_sock.c \ + pxe_connection.c pxe_http.c pxe_httpls.c httpfs.c + +CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../btx/lib \ + -I${.CURDIR}/../../../contrib/dev/acpica \ + -I${.CURDIR}/../../.. -I. -I$(.CURDIR)/.. -I${.CURDIR}/../libi386/ +# the location of libstand +CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ + +#debug flag +#CFLAGS+= -DPXE_DEBUG +#CFLAGS+= -DPXE_DEBUG_HELL + +# core module debug +#CFLAGS+= -DPXE_CORE_DEBUG_HELL +#CFLAGS+= -DPXE_CORE_DEBUG +# TCP module debug +#CFLAGS+= -DPXE_TCP_DEBUG +#CFLAGS+= -DPXE_TCP_DEBUG_HELL +# IP module debug +#CFLAGS+= -DPXE_IP_DEBUG +#CFLAGS+= -DPXE_IP_DEBUG_HELL +# ARP module debug +#CFLAGS+= -DPXE_ARP_DEBUG +#CFLAGS+= -DPXE_ARP_DEBUG_HELL +# httpfs module +#CFLAGS+= -DPXE_HTTP_DEBUG +#CFLAGS+= -DPXE_HTTP_DEBUG_HELL + +# define to get more PXE related code and testing functions +#CFLAGS+= -DPXE_MORE + +# define to get some speed up by bigger requests +CFLAGS+= -DPXE_HTTPFS_CACHING + +# define to send packets freqently to speed up connection +#CFLAGS+= -DPXE_TCP_AGRESSIVE + +# define to automatically choose non keep-alive method of +# working, if keep-alive is not supported by server +CFLAGS+= -DPXE_HTTP_AUTO_KEEPALIVE + +.include Added: user/sbruno/pxe_http/README ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/sbruno/pxe_http/README Tue Jan 15 00:39:15 2013 (r245442) @@ -0,0 +1,1256 @@ +Contents +---------- + +1. Introduction + + 1.2. Setting up + + 1.2.1. DHCP configuration + 1.2.2. TFTP configuration + 1.2.3. Web-server configuration + 1.2.4. loader.rc configuratuion + +2. Project organisation + + 2.1. Code modules + 2.2. Naming conventions + 2.3. Understanding logical structure of code + +3. API usage + + 3.1. Base information + 3.2. PXE sockets API overview + + 3.2.1. PXE API socket details + + 3.3. Quick Reference to API, available for user code + + 3.3.1. pxe_arp module + 3.3.2. pxe_await module + 3.3.3. pxe_buffer module + 3.3.4. pxe_connection module + 3.3.5. pxe_core module + 3.3.6. pxe_dhcp module + 3.3.7. pxe_dns module + 3.3.8. pxe_filter module + 3.3.9. pxe_http module + 3.3.10. httpfs module + 3.3.11. pxe_icmp module + 3.3.12. pxe_ip module + 3.3.13. pxe_isr module + 3.3.14. pxe_mem module + 3.3.15. pxe_sock module + 3.3.16. pxe_segment module + 3.3.17. pxe_tcp module + 3.3.18. pxe_udp module + +4. Debugging, testing and tuning pxe_http library. + + 4.1. Using 'pxe' loader's command + 4.2. Defining debug macroses + 4.3. Tuning + 4.4. NFS loading with pxe_http + +1. Introduction +---------------- + + pxe_http library is user space implementation of simplified + TCP/IP4 stack with support of sockets. Socket implementation is similar + to common sockets, but differs, so I call this variant of sockets - + "PXE sockets" + + features (read: simpliest ever implementation of): + * supports TCP/UDP PXE sockets + * DHCP client + * DNS client + * http based filesystem + * ICMP echo + +1.1. Requirements +------------------ + + To use pxeboot with extensions from pxe_http library + you need: + * DHCP server + - any DHCP server with support of some options + (see below). In example of configuration files + ISC DHCP v.3.0.5 was used. + * TFTP server + * Web server - I've used Apache 1.3.34 + + +1.2. Setting it up +------------------- + + In most cases, it's the same as for usual pxeboot. Main + difference is in configuration file of DHCP server and in usage of + Web-server. + + +1.2.1. DHCP configuration +------------------------- + + Here is example of configuration: + + # /etc/dhcpd.conf example + # + ddns-update-style none; + server-name "DHCPserver"; + server-identifier 192.168.0.4; + default-lease-time 7200; + max-lease-time 7200; + + # + # significant options for correct working of pxeboot + # + + # your LAN subnet mask + option subnet-mask 255.255.255.0; + + # default gateway to use + option routers 192.168.0.1; + + # name of file to download via TFTP + filename "pxeboot"; + + # name server, used for resolving of domain names + option domain-name-servers 192.168.0.1; + + # ip address of web server + option www-server 192.168.0.2; + + # path, where nessesary files are stored on web server + option root-path "th.lan:/path/to/root"; + + subnet 192.168.0.0 netmask 255.255.255.0 { + next-server 192.168.0.4; + range 192.168.0.10 192.168.0.20; + } + + /* end of example */ + + NOTES: + 1. www-server option is used only if root-path is absent in + DHCP reply. In that case assumed, that /boot directory is + placed in DocumentRoot of web-server. + 2. format of root-path has such format: "server:/path". It's + possible use both IP's and domain names for server. /path is + relative to DocumentRoot of web-server. In example above + files are stored at /usr/local/www/data/path/to/root, + assuming that /usr/local/www/data - is DocumentRoot. + 3. DHCP options are not greater then 255 bytes. So, root-path + must satisfy this requirement. + + +1.2.2. TFTP configuration +-------------------------- + + Same as usually. pxe_http doesn't directly use this protocol. + + +1.2.3. Web-server configuration +-------------------------------- + + Just copy all from "/boot" directory to + /DocumentRoot/path/to/root. + + NOTES: + 1. Need to be sure, that partial downloading and keep-alive + connections are supported by server. e.g. for Apache 1.x, + check this options: + + KeepAlive On + MaxKeepAliveRequests 10 # well, choose best for + # server + KeepAliveTimeout 15 # more then 2 seconds + # is good enough + + 1.1 Non keep-alive connections supported if macro + PXE_HTTP_AUTO_KEEPALIVE defined. In this case, non keep-alive + connections will be used if keep-alive are unavailable. + + 2. loader checks gzipped versions of files first, it's good + idea to compress every needed file. e.g. + beastie.4th.gz + device.hints + frames.4th.gz + loader.4th.gz + loader.conf + loader.help.gz + loader.rc + mfsroot.gz + screen.4th.gz + support.4th.gz + /kernel/kernel.gz + +1.2.4. loader.rc configuratuion +-------------------------------- + + HTTP downloading of kernel is not all need to startup system + correctly. The main question is where will be root filesystem after + booting of kernel. The simpliest way - is to use RAM drive with + installation tools or ready to work system. + Here is example of changes to loader.rc, that instructs loader + to download RAM-drive image (in this example, common mfsroot.gz found + in boot.flp floppy image file) + + + \ Includes additional commands + include /boot/loader.4th + + \ Reads and processes loader.conf variables + start + + \ Tests for password -- executes autoboot first if a password was defined + check-password + + \ Load in the boot menu + include /boot/beastie.4th + + \ pxe_http changes: + echo "loading RAM-drive image" + load -t mfs_root /boot/mfsroot + set vfs.root.mountfrom="ufs:/dev/md0c" + \ + + \ Start the boot menu + beastie-start + + /* end of example */ + + Of course, it's possible to set any other filesystem to work + as root, e,g, NFS and not use RAM drive. + +2. Project organisation +------------------------ + +2.1. Code modules +------------------ + + All project code is divided into following modules: + pxe_arp - ARP protocol (3.3.1) + pxe_await - provides functions for awaiting (3.3.2) + pxe_buffer - implements cyclic buffers (3.3.3) + pxe_connection - TCP connection related functions (3.3.4) + pxe_core - provides calls to PXE API (3.3.5) + pxe_dhcp - DHCP client (3.3.6) + pxe_dns - DNS client (3.3.7) + pxe_filter - incoming packet filters (3.3.8) + pxe_http - HTTP related functions (3.3.9) + httpfs - http based file system (3.3.10) + pxe_icmp - ICMP protocol (3.3.11) + pxe_ip - IP protocol (3.3.12) + pxe_isr - assembler side support for PXE API + calling (3.3.13) + pxe_mem - memory work routines (3.3.14) + pxe_sock - simple sockets (3.3.15) + pxe_segment - TCP segments (3.3.16) + pxe_tcp - TCP protocol (3.3.17) + pxe_udp - UDP protocol (3.3.18) + +2.2. Naming conventions +------------------------ + + Most of functions, that may be called directly by user API uses + pxe_ prefix. + Functions related to some module have subprefix of this module, + e.g. pxe_dhcp_query() - function related to DHCP module. + All structures, that are used have typedef equivalent with + naming in upper case. e.g. struct pxe_ipaddr has equivalent PXE_IPADDR. + This is done to have similar to existing pxe.h declarations from libi386. + + +2.3. Understanding logical structure of code +--------------------------------------------- + + Logicallly all modules may be divided to parts. + + Part 1: PXE API related modules (pxe_isr, pxe_core) + Part 2: base protocols related (pxe_ip, pxe_udp) + Part 3: sockets related (pxe_sock) + Part 4: other protocols (pxe_dns, pxe_dhcp) + Part 5: utility (pxe_mem, pxe_buffer) + + Some modules may be used independently, other depend on some + lower level modules. + + In run-time, many calls to sockets functions start packet + recieving or packet sending functions. Sending is more simplier and may + be assumed in many cases just as wrappers to PXE API. But receiving is + a little bit more complicated. Receiving functions start + pxe_core_recv_packets() function in cycle to get packets. + After receiving of packet, it's handling depends on it's type: + ARP, IP or other. ARP packets directly provided to handler + pxe_arp_protocol(), IP packets are provided to registered handler of IP + stack protocol, other packets are ignored. + Registration of handler (except ARP) is performed during + initialisation time of module with usage of pxe_core_register() function, + which register handler for IP stack protocol number. + So, packet is provided to handler, but it may be fragmented, + thus before processing it must be recieved completely. But in some cases + packet may be not interesting for protocol (unexpected packet, dublicated + or something else) and it's possible to determiny if this packet useful + just by examining of packet header. + If packet is fragmented - it firstly provided to handler with + flag PXE_CORE_FRAG. Handler returns appropriate value if is interested in + whole packet, packet is read completely from input queue of fragments and + provided again with flag PXE_CORE_HANDLE. Otherwise packet is dropped + in core by reading of all it's fragments from incoming queue. + Packet structure provides just buffer with received packet and + size of packet. All pxe_core module send/recieve functions work with + PXE_PACKET structure. + TCP and UDP protocols are checking filters in theirs handlers. + This helps to filter out packets that are not interesting for protocol + (e.g. to port that is not listening) + Socket and filter structures are separated. Socket provides + buffers for incoming and outcoming data. Filters may be used without + sockets, e.g. for TCP connections in TIME_WAIT state. For active + connection filter is used to determiny in which receiving buffer (in + which socket) must be placed incoming data. + + +3. API usage +------------- + + Here much attention paid to sockets, other pxe_http API + may be used less frequently. + +3.1. Base information +----------------------- + + User code must perform initialisation of pxe_core module (which + is performed currently in loader during pxe_enable() call). After this + sockets related functions become available. + + pxe_core_init() performs initialisation of pxe_core module and starts + initialisation routines of other modules. It inits TCP, UDP, ARP and + etc modules, however in most of cases it's possible skip theirs + initialisation if module's functions are unused. + Work is finished by pxe_core_shutdown() function. + + +3.2. PXE sockets API overview +------------------------------- + + PXE sockets API differs from common sockets. It's more simplier + and has some limitations due user space implementations. All socket + related functions are declared in pxe_sock.h header + + Socket is created by pxe_socket() call. After usage socket must + be closed by pxe_close() call. Result of pxe_socket() is integer + descriptor associated with socket. After creating socket is unbinded + and not connected. + pxe_sendto(), pxe_connect(), pxe_bind() functions performs + binding and connecting. After successful calling of one of them - socket + is in active state. It's possible to perform reading and sending from/to + socket. Cause socket API may use buffers to optimize packet sending + process, user code must call pxe_flush() functions to be sure, that + data is really processed to sending module. + While receiving need to keep in memory, that if UDP datagram is + not readed completely by one call of pxe_recv() in this implementation + rest of datagram is omited and lost for user code. + All incoming and outcoming data is written to socket buffers, + that have default sizes 16Kb and 4Kb. If buffers are full, next calls + related to writing or reading data will fail. + + +3.2.1. PXE API socket details +------------------------------ + + /* Here is simple example of API usage. */ + + int socket = pxe_socket(); + /* if result is not -1, then socket variable contains value, + * assosiated with socket structure. Call differs from common sockets, + * there are no domain, type and protocol parameters. + * Cause domain is always AF_INET now. others are use in pxe_connect() + * call. + */ + + int result = pxe_connect(socket, &hh->addr, 80, PXE_TCP_PROTOCOL); + /* This call creates filter, associates it with socket and establishes + * communication if needed. + * Parameters are socket, remote ip address (PXE_IPADDR), remote port + * and one of PXE_UDP_PROTOCOL and PXE_TCP_PROTOCOL protocols. + */ + + if (result == -1) { + pxe_close(socket); + /* any socket must be closed, even if it was not really used + * or conencted. pxe_close() call releases used internal + * structures. After this call any other operations with + * 'socket' descriptor are invalid. + */ + return (0); + } + + /* pxe_send() function sends data to socket. As usual, there is no + * guarantee, that whole buffer is transmited. And actually for TCP + * protocol, this call just places data to buffer. User code have no + * knowledge if data is really sent to network. if current segment is + * not fullly used, data may stay in buffer infinitely. + */ + if (len != pxe_send(socket, hh->buf, len)) { + /* failed to send data, at least whole buffer */ + pxe_close(socket); + return (0); + } + + /* if user code need guarantee, that data is sent to remote host, it + * must call pxe_flush(). It forces sending of any data, that must be + * sent. + */ + if (pxe_flush(socket) == -1) { + /* failed to flush socket */ + pxe_close(socket); + return (0); + } + + /* perform reading cycle */ + + while (count < maxsize) { + /* pxe_recv() is similar to recv() call for common sockets, + * but have no flags parameter + */ + result = pxe_recv(socket, &data[count], maxsize - count); + + if (result == -1) { /* failed to recv */ + break; + } + + if (result == 0) /* nothing received yet */ + continue; + + count += result; + } + + pxe_close(socket); + + + /* End of example */ + + +3.3 Quick Reference to API, available for user code +---------------------------------------------------- + + This overview covers functions and macro definitions that + may be usefull for user code. + + +3.3.1 pxe_arp module +--------------------- + + This module is used mainly by internal code while sending IP + packets. + +macro definitions: + +MAX_ARP_ENTRIES - how much may be ARP table in size. If ARP table full + and new MAC must be placed, then one of older entry is + replaced by new. Default number is 4. + +PXE_MAX_ARP_TRY - how much trys will be peformed when sending ARP + requests, before say MAC search failed. Default: 3 + +PXE_TIME_TO_DIE - how much time to wait ARP reply in milliseconds. + Default: 5000 ms. + +PXE_ARP_SNIFF - sometimes it's usefull to get senders MACs from + incoming requests (this may save time, MAC may be found + in table without requesting it by ARP module itself). + But if network is big enough - ARP table will be + updated too often. By default this option is defined. + + +functions: + +void pxe_arp_init() + - inits pxe_arp module. Usually this call is performed from + pxe_core_init() + +const MAC_ADDR *pxe_arp_ip4mac(const PXE_IPADDR *addr) + - returns MAC address for requested IP address + +void pxe_arp_stats() + - shows ARP table. Available if defined PXE_MORE macro. + + +3.3.2 pxe_await module +----------------------- + + Implements awaiting mechanism. Many operations are performed + similar in protocol implementations. Usually, packet is sended and + application awaits for reply. pxe_await() function helps to simplify + code in such case. + It starts await callback function with some flags and counts + timeouts, try count. + + Here is example of awaiting: + + /* we start awaiting, with dns_await() calllback function, maximum 4 + * trys, each try 20 seconds and waiting data static_wait_data. + * Waiting data - is some data associated with current awaiting, it's + * used by await callback function. + */ + if (!pxe_await(dns_await, 4, 20000, &static_wait_data)) + return (NULL); + + /* pxe_await() returns 1 if awaiting was successfull (await function + * returned PXE_AWAIT_COMPLETED flag) + */ + + /* it's an awaiting function. pxe_await() provides current function, + * current try number, time exceeded from start of try, pointer to + * associated wait data. + */ + int + dns_await(uint8_t function, uint16_t try_number, uint32_t timeout, + void *data) + { + /* cast to our type of wait data */ + PXE_DNS_WAIT_DATA *wait_data = (PXE_DNS_WAIT_DATA *)data; + + switch(function) { + + case PXE_AWAIT_STARTTRY: + /* is called at start of each try + * Here must be performed any await initialisation + * (e.g. request packet sending ) + */ + if (!dns_request(wait_data)) { + /* if initialisation of try failed, try more */ + return (PXE_AWAIT_NEXTTRY); + } + /* otherwise return success result of await function */ + break; + + case PXE_AWAIT_FINISHTRY: + /* this function is called at the end of any try (even + * if try was successful). Here cleanup must be + * performed. + */ + if (wait_data->socket != -1) + pxe_close(wait_data->socket); + + wait_data->id += 1; + break; + + case PXE_AWAIT_NEWPACKETS: + /* while waiting this function called if new packets + * were received by pxe_core_recv_packets(). Actually + * it may be not packets we are waiting for, may be + * even not packets with out protocol. Here we must + * check for new usefull for us packets, receive + * new data if any. + */ + size = pxe_recv(wait_data->socket, wait_data->data, + wait_data->size); + + parse_dns_reply(wait_data); + + if (wait_data->result.ip != 0) { + /* return success of awaiting. This may be + * returned from any function + */ + return (PXE_AWAIT_COMPLETED); + } + + /* if await was not completed, continue waiting */ + return (PXE_AWAIT_CONTINUE); + break; + + case PXE_AWAIT_END: + /* this called if await is ended without any result */ + default: + break; + } + + return (PXE_AWAIT_OK); + } + + /* end of example */ + + So, wait data used for providing and receiving data while + awaiting. pxe_await() performs unified working with code, needed for + waiting of incoming packets. + +macro definitions: + +TIME_DELTA_MS - delay between iterations during awaitng. At each + iteration are checked: + * receiving of new packet. If received - awaiting + function with PXE_AWAIT_NEWPACKETS function is called. + * try timeout. if timeout exceeds maximum timeout - + awaiting function with PXE_AWAIT_FINISHTRY and + PXE_AWAIT_STARTTRY flags sequentially are called. + * try count. if try count exceeds maximum - awaiting + function with PXE_AWAIT_ENDED flag is called. This + means that await failed. + Default: 1 + +TIME_DELTA - default: 1000, same as TIME_DELTA_MS, but in ticks + for delay. + + +3.3.3 pxe_buffer module +------------------------ + + This module provides reading and writing of cyclic buffers. + It's not used directly by user code. + +macro definitions: + +PXE_POOL_SLOTS - if defined, then statical allocation of buffers is + used. Otherwise buffers are allocated at run-time from + heap with pxe_alloc() function. Current statical + allocation algorithm is simple and square, there are + two big buffers data storages divided in slots (by + default 2). + Each slot has size equal to + PXE_DEFAULT_RECV_BUFSIZE or PXE_DEFAULT_SEND_BUFSIZE. + Depending on requested size in pxe_buffer_alloc() + function data allocated from one of stoarge and + related slot marked busy. When pxe_buffer_free() called, + slot marked as free. + Default: undefined + +PXE_DEFAULT_RECV_BUFSIZE - size of receiving buffer. Default: 16392 + +PXE_DEFAULT_SEND_BUFSIZE - size of sending buffer. Default: 4096 + + +3.3.4 pxe_connection module +---------------------------- + + This module is one of TCP related modules. It implements + connection entity. TCP connection is logical structure, that have + needed by TCP protocol counters and states. + User code is not directly works with this module. + +macro definitions: + +PXE_MAX_TCP_CONNECTIONS - how much simultaneous connections may be. + + +functions: + +void pxe_connection_stats() + - returns connections statistics. Available if PXE_MORE macro is + defined. + + +3.3.5 pxe_core module +---------------------- + + This module performs lowlevel work with PXE API: initialisation, + receiving/sending of packets, provides information functions. + In most cases, user code doesn't uses this module directly. + +macro definitions: + +PXE_BUFFER_SIZE - size of core buffers, used in PXE API calling, + Default: 4096 + +PXE_CORE_STATIC_BUFFERS - if defined, core buffers are allocated statically. + Otherwise they are allocated in heap. Default: defined + +functions: + +int pxe_core_recv_packets() + - recieves all packets waiting in incoming queue of NIC, and calls + appropriate protocols if needed + + +void pxe_core_register(uint8_t ip_proto, pxe_protocol_call proc) + - registers IP stack protocol, associates protocol number and handler. + +const MAC_ADDR *pxe_get_mymac() + - returns MAC of NIC, for which PXE API is used. + +const PXE_IPADDR *pxe_get_ip(uint8_t id) + - returns of stored IP, for provided id. + id may be: + PXE_IP_MY - NIC IP address + PXE_IP_NET - network adrress + PXE_IP_NETMASK - network mask + PXE_IP_NAMESERVER - nameserver to use in name resolving + PXE_IP_GATEWAY - default gateway + PXE_IP_BROADCAST - broadcast address + PXE_IP_SERVER - server from which loading of pxeboot + was performed + PXE_IP_WWW - IP address of http-server + PXE_IP_ROOT - IP adddress of server, where root + file system is situated. + +void pxe_set_ip(uint8_t id, const PXE_IPADDR *ip) + - sets value by it's id. + +time_t pxe_get_secs() + - returns time in seconds. Used in timeout and resend checking. + +types: + +typedef int (*pxe_protocol_call)(PXE_PACKET *pack, uint8_t function) + - protocol callback function type + + +3.3.6. pxe_dhcp module +----------------------- + + This module implements simple DHCP client, used to obtain + gateway, nameserver and other information. + + +macro definitions: + +PXE_BOOTP_USE_LIBSTAND - use bootp() function provided by libstand instead + of own DHCP client. NOTE: bootp() doesn't set nameip (nameserver ip + structure), thus DNS resolving will be impossible. Default: undefined + + NOTE: to use bootp(), also UDP_DEFAULT_SOCKET macro must be defined. + + +functions: + +void pxe_dhcp_query(uint32_t xid) + - sends DHCPDISCOVER packet and sets core_ips, if gets reply. + + +3.3.6. pxe_dns module +---------------------- + + This module provides domain name resolving. Actually + A and CNAME resource records are supported. + +macro definitions: + +PXE_MAX_DNS_TIMEOUT - max time to wait DNS reply in milliseconds. + Default: 10 seconds + +PXE_MAX_DNS_TRYS - how many times to try to resend request, + if there is no reply. Default: 3 + +PXE_DNS_MAX_PACKET_SIZE - maximum UDP packet size in bytes. Default: 512. + This DNS client doesn't support TCP for resolving. + +functions: + +const PXE_IPADDR *pxe_gethostbyname(char *name) + - returns IP, if resolved, for provided domain name. + +uint32_t pxe_convert_ipstr(char *str) + - converts string value of ipv4 to uint32_t value. + + +3.3.8. pxe_filter module +------------------------- + + This module is not supposed to be used by user code directly. + It implements filtering of incoming IP packets. It's used by UDP and + TCP modules for sorting packets in appropriate socket. + Module provides functions for adding and removing filters. + Each filter contains source/destination ip:port definition and masks + for all of them. Usage of masks gives opportunity to recieve data + from subnet, or subset of ports. + +functions: + +void pxe_filter_init() + - inits filter module structures such as list of free filter entries. + +void pxe_filter_stats() + - show active filters information. Used for debugging. Available if + PXE_MORE macro defined. + + +3.3.9. pxe_http module +----------------------- + + pxe_http implements functions for getting files via HTTP. + Most of it's functions are used only by httpfs module. + At opening file pxe_exists() function is called, which + gets filesize (if possible) by HEAD method of request and opens + connection to file. Result of pxe_exists() call is keep-alive + connection to file. + pxe_get() function gets needed data and reestablishes + connection if needed. + if PXE_MORE defined - pxe_get_close() function becomes + available. It opens connection, gets portion of data and closes + connection. It's rather not optimal usage of http connections, + but some times it may be needed (e.g. for servers, where keep + alive connections are prohibited). + +macro definitions: + +PXE_MAX_HTTP_HDRLEN - buffer size for generating/getting http header. + Default: 1024 bytes. + +functions: + +int pxe_fetch(char *server, char *filename, off_t from, size_t size) + - testing function, gets file from server ()may be partially) and + outputs received data to screen. Available if PXE_MORE defined. + + +3.3.10. httpfs module +---------------------- + + httpfs is filesystem, available via HTTP. It is read-only + filesystem, mainly with sequential access to files. It exports + file operations structure and is not used directly by user code. + httpfs module may support some kind of caching: it requests + more data per request then it's needed at http_read() call and + reads this data later. Such approach speed ups connections speed + and reduces server load. + This opportunity is available if PXE_HTTPFS_CACHING macro + is defined. + + +3.3.11. pxe_icmp module +------------------------ + + pxe_icmp module provides some basic functionality of ICMP + protocol: echo requesting/replying. + Module is unavailable, if PXE_MORE undefined. + + +macro definitions: + +PXE_ICMP_TIMEOUT - timeout in milliseconds when waiting echo reply. + Default: 5000 ms. + + +functions: + +int pxe_ping(const PXE_IPADDR *ip, int count, int flags) + - works similar to usual ping, sends echo request and shows timeout + before echo reply. + +int pxe_icmp_init() + - inits module + + +3.3.12. pxe_ip module +---------------------- + + This module implemets IP protocol functions, also it works + with routing table. It also declares PXE_IPADDR, that is used widely. + +macro definitions: + +PXE_MAX_ROUTES - route table size. Default: 4, usually used 2 entries. + + +functions: + +uint16_t pxe_ip_checksum(const void *data, size_t size) + - calculates checksum for provided block of data. + + +void pxe_ip_route_init(const PXE_IPADDR *def_gw) + - inits routing table, sets default gateway + + +int pxe_ip_route_add(const PXE_IPADDR *net, uint32_t mask, + const PXE_IPADDR *gw) + - adds route to routing table + +int pxe_ip_route_del(const PXE_IPADDR *net, uint32_t mask, + const PXE_IPADDR *gw) + - dels route from routing table + +uint32_t pxe_ip_get_netmask(const PXE_IPADDR *ip) + - returns class based netmask for ip. + +int pxe_ip_route_default(const PXE_IPADDR *gw) + - adds default gateway + +int pxe_ip_send(void *data, const PXE_IPADDR *dst, uint8_t protocol, + uint16_t size) + - sends ip packet with provided data. There must be space for + IP header in buffer, pointed by data. + +void pxe_ip_route_stat() + - show route table. Available if PXE_MORE defined + + +3.3.13. pxe_isr module +----------------------- + + Contains assembler side functions, used in pxe_core. + User code has no direct access to them. + There supported: installation/removing of interrupt handler, + interrupt handler and wrapper for PXE API calls. + + +3.3.14. pxe_mem module +----------------------- + + Actually this module just a wrapper to bcopy(), alloc() and free() + functions. That's done to make pxe_http library more portable. + But in fact, pxe_http depends much on other libstand functions, + such as printf(), strcpy() and etc. So this module is not very usefull and + will be probably removed in future. + + +3.3.15. pxe_sock module +------------------------ + + Most used by user code module. Contains implementation of + pxe_http sockets API. + + +macro definitions: + +PXE_DEFAULT_SOCKETS - count of sockets used at the same time. If all + socket structures are used, next socket creating calls + and API that depends on it, will fail. Default: 4 + + +PXE_SOCKET_TIMEOUT - how long pxe_recv() will be wiating incoming data per + call before return error. Default: 30000 ms + +PXE_SOCKET_CHECK_TIMEOUT - If pxe_recv() waits incoming data and have big free + space in buffer, and in case of TCP protocol it may notice + remote server about this by sending empty packet (with + no data) acking current state, so remote host updates + knowledge about receiving window of client and sends new + data. + That option specifies how long pxe_recv() will + be waiting before checking TCP connection. In fast + environments like LAN it speed ups connection when huge + amount of data is transmitted, in WAN it's not very + useful. + Default: 100 ms. This option works only if + PXE_TCP_AGRESSIVE macro is defined. + +PXE_SOCKET_ACCURATE - adds extra socket validating at head of every + socket related function, available to user. + By default: defined. + +functions: + +void pxe_sock_init() + - inits socket API module. + +void pxe_sock_stats() + - prints out to screen socket usage statistics. Available if PXE_MORE + macro defined. + +int pxe_sock_state(int socket) + - return current socket state. May be one of this states: + PXE_SOCKET_BINDED, PXE_SOCKET_CONNECTED, PXE_SOCKET_ESTABLISHED. + It may be used for checking, if connection was breaked. + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Tue Jan 15 01:33:20 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 2896387B; Tue, 15 Jan 2013 01:33:20 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 03406A25; Tue, 15 Jan 2013 01:33:20 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0F1XJfv011773; Tue, 15 Jan 2013 01:33:19 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0F1XJ4U011772; Tue, 15 Jan 2013 01:33:19 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201301150133.r0F1XJ4U011772@svn.freebsd.org> From: Sean Bruno Date: Tue, 15 Jan 2013 01:33:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245445 - user/sbruno/pxestuff X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jan 2013 01:33:20 -0000 Author: sbruno Date: Tue Jan 15 01:33:19 2013 New Revision: 245445 URL: http://svnweb.freebsd.org/changeset/base/245445 Log: Branch head to see if I can thwack this pxe_http stuff into existence again Added: - copied from r245444, head/ Directory Properties: user/sbruno/pxestuff/ (props changed) From owner-svn-src-user@FreeBSD.ORG Wed Jan 16 01:49:09 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 7AD9E481; Wed, 16 Jan 2013 01:49:09 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 611EED4E; Wed, 16 Jan 2013 01:49:09 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0G1n9ph026599; Wed, 16 Jan 2013 01:49:09 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0G1n8Wl026588; Wed, 16 Jan 2013 01:49:08 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201301160149.r0G1n8Wl026588@svn.freebsd.org> From: Sean Bruno Date: Wed, 16 Jan 2013 01:49:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245486 - in user/sbruno/pxestuff/sys/boot/i386: . btx/btx btx/lib libi386 pxehttp X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jan 2013 01:49:09 -0000 Author: sbruno Date: Wed Jan 16 01:49:07 2013 New Revision: 245486 URL: http://svnweb.freebsd.org/changeset/base/245486 Log: First day of work on pxe_http restoral, merge in some janky assembly that better get some serious reviews from people whom are way smarter than I. Added: user/sbruno/pxestuff/sys/boot/i386/pxehttp/ user/sbruno/pxestuff/sys/boot/i386/pxehttp/Makefile user/sbruno/pxestuff/sys/boot/i386/pxehttp/README user/sbruno/pxestuff/sys/boot/i386/pxehttp/httpfs.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/httpfs.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_arp.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_arp.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_await.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_await.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_buffer.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_buffer.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_connection.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_connection.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_core.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_core.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_dhcp.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_dhcp.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_dns.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_dns.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_filter.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_filter.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_http.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_http.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_httpls.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_httpls.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_icmp.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_icmp.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_ip.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_ip.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_ip6.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_isr.S user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_isr.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_mem.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_mem.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_segment.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_segment.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_sock.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_sock.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_tcp.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_tcp.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_udp.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_udp.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/socketfs.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/socketfs.h Modified: user/sbruno/pxestuff/sys/boot/i386/Makefile user/sbruno/pxestuff/sys/boot/i386/btx/btx/btx.S user/sbruno/pxestuff/sys/boot/i386/btx/lib/btxsys.s user/sbruno/pxestuff/sys/boot/i386/btx/lib/btxv86.h user/sbruno/pxestuff/sys/boot/i386/libi386/Makefile Modified: user/sbruno/pxestuff/sys/boot/i386/Makefile ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/Makefile Wed Jan 16 01:30:46 2013 (r245485) +++ user/sbruno/pxestuff/sys/boot/i386/Makefile Wed Jan 16 01:49:07 2013 (r245486) @@ -3,7 +3,7 @@ .include SUBDIR= mbr pmbr boot0 boot0sio btx boot2 cdboot gptboot kgzldr \ - libi386 libfirewire loader + libi386 libfirewire pxehttp loader # special boot programs, 'self-extracting boot2+loader' SUBDIR+= pxeldr Modified: user/sbruno/pxestuff/sys/boot/i386/btx/btx/btx.S ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/btx/btx/btx.S Wed Jan 16 01:30:46 2013 (r245485) +++ user/sbruno/pxestuff/sys/boot/i386/btx/btx/btx.S Wed Jan 16 01:49:07 2013 (r245486) @@ -52,7 +52,8 @@ .set SEL_RDATA,0x20 # Real mode data .set SEL_UCODE,0x28|3 # User code .set SEL_UDATA,0x30|3 # User data - .set SEL_TSS,0x38 # TSS + .set SEL_TSS,0x38 # TSS + .set SEL_CALLGATE,0x40 # super2user callgate /* * Task state segment fields. */ @@ -62,8 +63,9 @@ /* * System calls. */ - .set SYS_EXIT,0x0 # Exit - .set SYS_EXEC,0x1 # Exec + .set SYS_EXIT,0x0 # Exit + .set SYS_EXEC,0x1 # Exec + .set SYS_ISR_INSTALL,0x2 # ISR_install /* * Fields in V86 interface structure. */ @@ -366,7 +368,6 @@ except.2: pushl 0x50(%esp,1) # Set ESP popl %es # data movl %esp,%ebx # Stack frame movl $dmpfmt,%esi # Dump format string - movl $MEM_BUF,%edi # Buffer pushl %edi # Dump to call dump # buffer popl %esi # and @@ -690,7 +691,9 @@ rret_tramp.3: popl %es # Restore /* * System Call. */ -intx30: cmpl $SYS_EXEC,%eax # Exec system call? +intx30: cmpl $SYS_ISR_INSTALL, %eax # is isr_install? + je intx30.2 # yes + cmpl $SYS_EXEC,%eax # Exec system call? jne intx30.1 # No pushl %ss # Set up popl %es # all @@ -708,6 +711,74 @@ intx30: cmpl $SYS_EXEC,%eax # Exec sys intx30.1: orb $0x1,%ss:btx_hdr+0x7 # Flag reboot jmp exit # Exit /* + * Here we need to modify IDT in such way, that at interrupt handle + * will be run isr_trump, which role is to run provided function + * in user space. + */ +intx30.2: + cli + pushl %edi + pushl %ebx + pushw %ds + pushw %dx + + pushl %ss # Set up + popl %ds # registers + + + movl $MEM_USR,%ebx # User base address + addl 0x18(%esp,1),%ebx # getting user stack head + addl $0x04, %ebx # first parameter + + movl (%ebx), %eax + movw 0x2(%ebx), %dx + xchgw %dx, %bx + +/* + * updating call gate + */ + movl $callgate, %edi + movw %ax, (%edi) # +0: store offset 00..15 + shr $0x10 ,%eax # getting high word + movw %ax, 0x06(%edi) # +6: handler offset 16..31 +/* + * installing handler + */ +/* + * NOTE: it seems nothing else must be done + */ + popw %dx + popw %ds + popl %ebx + popl %edi + sti + iret # return from syscall + +user_isr_call: +/* + * NOTE: isr must use lret to return and restore SS, ESP, CS, EIP. +*/ + pushl %ds # saving ds + pushl %edi + movl $SEL_SDATA, %eax # + movl %eax, %ds + + movl $callgate, %edi + movw (%edi), %ax + popl %edi + + cmpw $0x0000, %ax + je isr_ret + + lcall $SEL_CALLGATE,$0x00000000 # far call via callgate selector + # offset is ignored +isr_ret: + + + popl %ds + + iret # return from interrupt handler +/* * Dump structure [EBX] to [EDI], using format string [ESI]. */ dump.0: stosb # Save char @@ -1000,6 +1071,7 @@ gdt: .word 0x0,0x0,0x0,0x0 # Null entr .word 0xffff,MEM_USR,0xfa00,0xcf# SEL_UCODE .word 0xffff,MEM_USR,0xf200,0xcf# SEL_UDATA tss_desc: .word _TSSLM,MEM_TSS,0x8900,0x0 # SEL_TSS +callgate: .word 0x0, SEL_UCODE,0xec00,0x0 # SEL_CALLGATE gdt.1: /* * Pseudo-descriptors. Modified: user/sbruno/pxestuff/sys/boot/i386/btx/lib/btxsys.s ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/btx/lib/btxsys.s Wed Jan 16 01:30:46 2013 (r245485) +++ user/sbruno/pxestuff/sys/boot/i386/btx/lib/btxsys.s Wed Jan 16 01:49:07 2013 (r245486) @@ -24,6 +24,7 @@ # .global __exit .global __exec + .global __isr_install # # Constants. # @@ -38,3 +39,8 @@ __exit: xorl %eax,%eax # BTX system # __exec: movl $0x1,%eax # BTX system int $INT_SYS # call 0x1 +# +# System call: isr_install +# +__isr_install: movl $0x2,%eax # BTX system + int $INT_SYS # call 0x2 Modified: user/sbruno/pxestuff/sys/boot/i386/btx/lib/btxv86.h ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/btx/lib/btxv86.h Wed Jan 16 01:30:46 2013 (r245485) +++ user/sbruno/pxestuff/sys/boot/i386/btx/lib/btxv86.h Wed Jan 16 01:49:07 2013 (r245486) @@ -64,4 +64,9 @@ extern u_int32_t __args; void __exit(int) __attribute__((__noreturn__)); void __exec(caddr_t, ...); +/* + * Installs interrupt handler function for interrupt int_num. + * caddr_t - in userspace. + */ +void __isr_install(caddr_t isr, uint16_t int_num); #endif /* !_BTXV86_H_ */ Modified: user/sbruno/pxestuff/sys/boot/i386/libi386/Makefile ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/libi386/Makefile Wed Jan 16 01:30:46 2013 (r245485) +++ user/sbruno/pxestuff/sys/boot/i386/libi386/Makefile Wed Jan 16 01:49:07 2013 (r245486) @@ -48,7 +48,7 @@ CFLAGS+= -Dalloca=__builtin_alloca CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../common \ -I${.CURDIR}/../btx/lib \ -I${.CURDIR}/../../../contrib/dev/acpica/include \ - -I${.CURDIR}/../../.. -I. + -I${.CURDIR}/../../.. -I. -I${.CURDIR}/../pxe_http/ # the location of libstand CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ Added: user/sbruno/pxestuff/sys/boot/i386/pxehttp/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/sbruno/pxestuff/sys/boot/i386/pxehttp/Makefile Wed Jan 16 01:49:07 2013 (r245486) @@ -0,0 +1,50 @@ +# pxe_http project +# +LIB= pxe_http +INTERNALLIB= + +SRCS= pxe_isr.S pxe_mem.c pxe_buffer.c pxe_await.c pxe_arp.c pxe_ip.c \ + pxe_core.c pxe_icmp.c pxe_udp.c pxe_filter.c pxe_dns.c \ + pxe_dhcp.c pxe_segment.c pxe_tcp.c pxe_sock.c \ + pxe_connection.c pxe_http.c pxe_httpls.c httpfs.c + +CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../btx/lib \ + -I${.CURDIR}/../../../contrib/dev/acpica \ + -I${.CURDIR}/../../.. -I. -I$(.CURDIR)/.. -I${.CURDIR}/../libi386/ +# the location of libstand +CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ + +#debug flag +#CFLAGS+= -DPXE_DEBUG +#CFLAGS+= -DPXE_DEBUG_HELL + +# core module debug +#CFLAGS+= -DPXE_CORE_DEBUG_HELL +#CFLAGS+= -DPXE_CORE_DEBUG +# TCP module debug +#CFLAGS+= -DPXE_TCP_DEBUG +#CFLAGS+= -DPXE_TCP_DEBUG_HELL +# IP module debug +#CFLAGS+= -DPXE_IP_DEBUG +#CFLAGS+= -DPXE_IP_DEBUG_HELL +# ARP module debug +#CFLAGS+= -DPXE_ARP_DEBUG +#CFLAGS+= -DPXE_ARP_DEBUG_HELL +# httpfs module +#CFLAGS+= -DPXE_HTTP_DEBUG +#CFLAGS+= -DPXE_HTTP_DEBUG_HELL + +# define to get more PXE related code and testing functions +#CFLAGS+= -DPXE_MORE + +# define to get some speed up by bigger requests +CFLAGS+= -DPXE_HTTPFS_CACHING + +# define to send packets freqently to speed up connection +#CFLAGS+= -DPXE_TCP_AGRESSIVE + +# define to automatically choose non keep-alive method of +# working, if keep-alive is not supported by server +CFLAGS+= -DPXE_HTTP_AUTO_KEEPALIVE + +.include Added: user/sbruno/pxestuff/sys/boot/i386/pxehttp/README ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/sbruno/pxestuff/sys/boot/i386/pxehttp/README Wed Jan 16 01:49:07 2013 (r245486) @@ -0,0 +1,1256 @@ +Contents +---------- + +1. Introduction + + 1.2. Setting up + + 1.2.1. DHCP configuration + 1.2.2. TFTP configuration + 1.2.3. Web-server configuration + 1.2.4. loader.rc configuratuion + +2. Project organisation + + 2.1. Code modules + 2.2. Naming conventions + 2.3. Understanding logical structure of code + +3. API usage + + 3.1. Base information + 3.2. PXE sockets API overview + + 3.2.1. PXE API socket details + + 3.3. Quick Reference to API, available for user code + + 3.3.1. pxe_arp module + 3.3.2. pxe_await module + 3.3.3. pxe_buffer module + 3.3.4. pxe_connection module + 3.3.5. pxe_core module + 3.3.6. pxe_dhcp module + 3.3.7. pxe_dns module + 3.3.8. pxe_filter module + 3.3.9. pxe_http module + 3.3.10. httpfs module + 3.3.11. pxe_icmp module + 3.3.12. pxe_ip module + 3.3.13. pxe_isr module + 3.3.14. pxe_mem module + 3.3.15. pxe_sock module + 3.3.16. pxe_segment module + 3.3.17. pxe_tcp module + 3.3.18. pxe_udp module + +4. Debugging, testing and tuning pxe_http library. + + 4.1. Using 'pxe' loader's command + 4.2. Defining debug macroses + 4.3. Tuning + 4.4. NFS loading with pxe_http + +1. Introduction +---------------- + + pxe_http library is user space implementation of simplified + TCP/IP4 stack with support of sockets. Socket implementation is similar + to common sockets, but differs, so I call this variant of sockets - + "PXE sockets" + + features (read: simpliest ever implementation of): + * supports TCP/UDP PXE sockets + * DHCP client + * DNS client + * http based filesystem + * ICMP echo + +1.1. Requirements +------------------ + + To use pxeboot with extensions from pxe_http library + you need: + * DHCP server + - any DHCP server with support of some options + (see below). In example of configuration files + ISC DHCP v.3.0.5 was used. + * TFTP server + * Web server - I've used Apache 1.3.34 + + +1.2. Setting it up +------------------- + + In most cases, it's the same as for usual pxeboot. Main + difference is in configuration file of DHCP server and in usage of + Web-server. + + +1.2.1. DHCP configuration +------------------------- + + Here is example of configuration: + + # /etc/dhcpd.conf example + # + ddns-update-style none; + server-name "DHCPserver"; + server-identifier 192.168.0.4; + default-lease-time 7200; + max-lease-time 7200; + + # + # significant options for correct working of pxeboot + # + + # your LAN subnet mask + option subnet-mask 255.255.255.0; + + # default gateway to use + option routers 192.168.0.1; + + # name of file to download via TFTP + filename "pxeboot"; + + # name server, used for resolving of domain names + option domain-name-servers 192.168.0.1; + + # ip address of web server + option www-server 192.168.0.2; + + # path, where nessesary files are stored on web server + option root-path "th.lan:/path/to/root"; + + subnet 192.168.0.0 netmask 255.255.255.0 { + next-server 192.168.0.4; + range 192.168.0.10 192.168.0.20; + } + + /* end of example */ + + NOTES: + 1. www-server option is used only if root-path is absent in + DHCP reply. In that case assumed, that /boot directory is + placed in DocumentRoot of web-server. + 2. format of root-path has such format: "server:/path". It's + possible use both IP's and domain names for server. /path is + relative to DocumentRoot of web-server. In example above + files are stored at /usr/local/www/data/path/to/root, + assuming that /usr/local/www/data - is DocumentRoot. + 3. DHCP options are not greater then 255 bytes. So, root-path + must satisfy this requirement. + + +1.2.2. TFTP configuration +-------------------------- + + Same as usually. pxe_http doesn't directly use this protocol. + + +1.2.3. Web-server configuration +-------------------------------- + + Just copy all from "/boot" directory to + /DocumentRoot/path/to/root. + + NOTES: + 1. Need to be sure, that partial downloading and keep-alive + connections are supported by server. e.g. for Apache 1.x, + check this options: + + KeepAlive On + MaxKeepAliveRequests 10 # well, choose best for + # server + KeepAliveTimeout 15 # more then 2 seconds + # is good enough + + 1.1 Non keep-alive connections supported if macro + PXE_HTTP_AUTO_KEEPALIVE defined. In this case, non keep-alive + connections will be used if keep-alive are unavailable. + + 2. loader checks gzipped versions of files first, it's good + idea to compress every needed file. e.g. + beastie.4th.gz + device.hints + frames.4th.gz + loader.4th.gz + loader.conf + loader.help.gz + loader.rc + mfsroot.gz + screen.4th.gz + support.4th.gz + /kernel/kernel.gz + +1.2.4. loader.rc configuratuion +-------------------------------- + + HTTP downloading of kernel is not all need to startup system + correctly. The main question is where will be root filesystem after + booting of kernel. The simpliest way - is to use RAM drive with + installation tools or ready to work system. + Here is example of changes to loader.rc, that instructs loader + to download RAM-drive image (in this example, common mfsroot.gz found + in boot.flp floppy image file) + + + \ Includes additional commands + include /boot/loader.4th + + \ Reads and processes loader.conf variables + start + + \ Tests for password -- executes autoboot first if a password was defined + check-password + + \ Load in the boot menu + include /boot/beastie.4th + + \ pxe_http changes: + echo "loading RAM-drive image" + load -t mfs_root /boot/mfsroot + set vfs.root.mountfrom="ufs:/dev/md0c" + \ + + \ Start the boot menu + beastie-start + + /* end of example */ + + Of course, it's possible to set any other filesystem to work + as root, e,g, NFS and not use RAM drive. + +2. Project organisation +------------------------ + +2.1. Code modules +------------------ + + All project code is divided into following modules: + pxe_arp - ARP protocol (3.3.1) + pxe_await - provides functions for awaiting (3.3.2) + pxe_buffer - implements cyclic buffers (3.3.3) + pxe_connection - TCP connection related functions (3.3.4) + pxe_core - provides calls to PXE API (3.3.5) + pxe_dhcp - DHCP client (3.3.6) + pxe_dns - DNS client (3.3.7) + pxe_filter - incoming packet filters (3.3.8) + pxe_http - HTTP related functions (3.3.9) + httpfs - http based file system (3.3.10) + pxe_icmp - ICMP protocol (3.3.11) + pxe_ip - IP protocol (3.3.12) + pxe_isr - assembler side support for PXE API + calling (3.3.13) + pxe_mem - memory work routines (3.3.14) + pxe_sock - simple sockets (3.3.15) + pxe_segment - TCP segments (3.3.16) + pxe_tcp - TCP protocol (3.3.17) + pxe_udp - UDP protocol (3.3.18) + +2.2. Naming conventions +------------------------ + + Most of functions, that may be called directly by user API uses + pxe_ prefix. + Functions related to some module have subprefix of this module, + e.g. pxe_dhcp_query() - function related to DHCP module. + All structures, that are used have typedef equivalent with + naming in upper case. e.g. struct pxe_ipaddr has equivalent PXE_IPADDR. + This is done to have similar to existing pxe.h declarations from libi386. + + +2.3. Understanding logical structure of code +--------------------------------------------- + + Logicallly all modules may be divided to parts. + + Part 1: PXE API related modules (pxe_isr, pxe_core) + Part 2: base protocols related (pxe_ip, pxe_udp) + Part 3: sockets related (pxe_sock) + Part 4: other protocols (pxe_dns, pxe_dhcp) + Part 5: utility (pxe_mem, pxe_buffer) + + Some modules may be used independently, other depend on some + lower level modules. + + In run-time, many calls to sockets functions start packet + recieving or packet sending functions. Sending is more simplier and may + be assumed in many cases just as wrappers to PXE API. But receiving is + a little bit more complicated. Receiving functions start + pxe_core_recv_packets() function in cycle to get packets. + After receiving of packet, it's handling depends on it's type: + ARP, IP or other. ARP packets directly provided to handler + pxe_arp_protocol(), IP packets are provided to registered handler of IP + stack protocol, other packets are ignored. + Registration of handler (except ARP) is performed during + initialisation time of module with usage of pxe_core_register() function, + which register handler for IP stack protocol number. + So, packet is provided to handler, but it may be fragmented, + thus before processing it must be recieved completely. But in some cases + packet may be not interesting for protocol (unexpected packet, dublicated + or something else) and it's possible to determiny if this packet useful + just by examining of packet header. + If packet is fragmented - it firstly provided to handler with + flag PXE_CORE_FRAG. Handler returns appropriate value if is interested in + whole packet, packet is read completely from input queue of fragments and + provided again with flag PXE_CORE_HANDLE. Otherwise packet is dropped + in core by reading of all it's fragments from incoming queue. + Packet structure provides just buffer with received packet and + size of packet. All pxe_core module send/recieve functions work with + PXE_PACKET structure. + TCP and UDP protocols are checking filters in theirs handlers. + This helps to filter out packets that are not interesting for protocol + (e.g. to port that is not listening) + Socket and filter structures are separated. Socket provides + buffers for incoming and outcoming data. Filters may be used without + sockets, e.g. for TCP connections in TIME_WAIT state. For active + connection filter is used to determiny in which receiving buffer (in + which socket) must be placed incoming data. + + +3. API usage +------------- + + Here much attention paid to sockets, other pxe_http API + may be used less frequently. + +3.1. Base information +----------------------- + + User code must perform initialisation of pxe_core module (which + is performed currently in loader during pxe_enable() call). After this + sockets related functions become available. + + pxe_core_init() performs initialisation of pxe_core module and starts + initialisation routines of other modules. It inits TCP, UDP, ARP and + etc modules, however in most of cases it's possible skip theirs + initialisation if module's functions are unused. + Work is finished by pxe_core_shutdown() function. + + +3.2. PXE sockets API overview +------------------------------- + + PXE sockets API differs from common sockets. It's more simplier + and has some limitations due user space implementations. All socket + related functions are declared in pxe_sock.h header + + Socket is created by pxe_socket() call. After usage socket must + be closed by pxe_close() call. Result of pxe_socket() is integer + descriptor associated with socket. After creating socket is unbinded + and not connected. + pxe_sendto(), pxe_connect(), pxe_bind() functions performs + binding and connecting. After successful calling of one of them - socket + is in active state. It's possible to perform reading and sending from/to + socket. Cause socket API may use buffers to optimize packet sending + process, user code must call pxe_flush() functions to be sure, that + data is really processed to sending module. + While receiving need to keep in memory, that if UDP datagram is + not readed completely by one call of pxe_recv() in this implementation + rest of datagram is omited and lost for user code. + All incoming and outcoming data is written to socket buffers, + that have default sizes 16Kb and 4Kb. If buffers are full, next calls + related to writing or reading data will fail. + + +3.2.1. PXE API socket details +------------------------------ + + /* Here is simple example of API usage. */ + + int socket = pxe_socket(); + /* if result is not -1, then socket variable contains value, + * assosiated with socket structure. Call differs from common sockets, + * there are no domain, type and protocol parameters. + * Cause domain is always AF_INET now. others are use in pxe_connect() + * call. + */ + + int result = pxe_connect(socket, &hh->addr, 80, PXE_TCP_PROTOCOL); + /* This call creates filter, associates it with socket and establishes + * communication if needed. + * Parameters are socket, remote ip address (PXE_IPADDR), remote port + * and one of PXE_UDP_PROTOCOL and PXE_TCP_PROTOCOL protocols. + */ + + if (result == -1) { + pxe_close(socket); + /* any socket must be closed, even if it was not really used + * or conencted. pxe_close() call releases used internal + * structures. After this call any other operations with + * 'socket' descriptor are invalid. + */ + return (0); + } + + /* pxe_send() function sends data to socket. As usual, there is no + * guarantee, that whole buffer is transmited. And actually for TCP + * protocol, this call just places data to buffer. User code have no + * knowledge if data is really sent to network. if current segment is + * not fullly used, data may stay in buffer infinitely. + */ + if (len != pxe_send(socket, hh->buf, len)) { + /* failed to send data, at least whole buffer */ + pxe_close(socket); + return (0); + } + + /* if user code need guarantee, that data is sent to remote host, it + * must call pxe_flush(). It forces sending of any data, that must be + * sent. + */ + if (pxe_flush(socket) == -1) { + /* failed to flush socket */ + pxe_close(socket); + return (0); + } + + /* perform reading cycle */ + + while (count < maxsize) { + /* pxe_recv() is similar to recv() call for common sockets, + * but have no flags parameter + */ + result = pxe_recv(socket, &data[count], maxsize - count); + + if (result == -1) { /* failed to recv */ + break; + } + + if (result == 0) /* nothing received yet */ + continue; + + count += result; + } + + pxe_close(socket); + + + /* End of example */ + + +3.3 Quick Reference to API, available for user code +---------------------------------------------------- + + This overview covers functions and macro definitions that + may be usefull for user code. + + +3.3.1 pxe_arp module +--------------------- + + This module is used mainly by internal code while sending IP + packets. + +macro definitions: + +MAX_ARP_ENTRIES - how much may be ARP table in size. If ARP table full + and new MAC must be placed, then one of older entry is + replaced by new. Default number is 4. + +PXE_MAX_ARP_TRY - how much trys will be peformed when sending ARP + requests, before say MAC search failed. Default: 3 + +PXE_TIME_TO_DIE - how much time to wait ARP reply in milliseconds. + Default: 5000 ms. + +PXE_ARP_SNIFF - sometimes it's usefull to get senders MACs from + incoming requests (this may save time, MAC may be found + in table without requesting it by ARP module itself). + But if network is big enough - ARP table will be + updated too often. By default this option is defined. + + +functions: + +void pxe_arp_init() + - inits pxe_arp module. Usually this call is performed from + pxe_core_init() + +const MAC_ADDR *pxe_arp_ip4mac(const PXE_IPADDR *addr) + - returns MAC address for requested IP address + +void pxe_arp_stats() + - shows ARP table. Available if defined PXE_MORE macro. + + +3.3.2 pxe_await module +----------------------- + + Implements awaiting mechanism. Many operations are performed + similar in protocol implementations. Usually, packet is sended and + application awaits for reply. pxe_await() function helps to simplify + code in such case. + It starts await callback function with some flags and counts + timeouts, try count. + + Here is example of awaiting: + + /* we start awaiting, with dns_await() calllback function, maximum 4 + * trys, each try 20 seconds and waiting data static_wait_data. + * Waiting data - is some data associated with current awaiting, it's + * used by await callback function. + */ + if (!pxe_await(dns_await, 4, 20000, &static_wait_data)) + return (NULL); + + /* pxe_await() returns 1 if awaiting was successfull (await function + * returned PXE_AWAIT_COMPLETED flag) + */ + + /* it's an awaiting function. pxe_await() provides current function, + * current try number, time exceeded from start of try, pointer to + * associated wait data. + */ + int + dns_await(uint8_t function, uint16_t try_number, uint32_t timeout, + void *data) + { + /* cast to our type of wait data */ + PXE_DNS_WAIT_DATA *wait_data = (PXE_DNS_WAIT_DATA *)data; + + switch(function) { + + case PXE_AWAIT_STARTTRY: + /* is called at start of each try + * Here must be performed any await initialisation + * (e.g. request packet sending ) + */ + if (!dns_request(wait_data)) { + /* if initialisation of try failed, try more */ + return (PXE_AWAIT_NEXTTRY); + } + /* otherwise return success result of await function */ + break; + + case PXE_AWAIT_FINISHTRY: + /* this function is called at the end of any try (even + * if try was successful). Here cleanup must be + * performed. + */ + if (wait_data->socket != -1) + pxe_close(wait_data->socket); + + wait_data->id += 1; + break; + + case PXE_AWAIT_NEWPACKETS: + /* while waiting this function called if new packets + * were received by pxe_core_recv_packets(). Actually + * it may be not packets we are waiting for, may be + * even not packets with out protocol. Here we must + * check for new usefull for us packets, receive + * new data if any. + */ + size = pxe_recv(wait_data->socket, wait_data->data, + wait_data->size); + + parse_dns_reply(wait_data); + + if (wait_data->result.ip != 0) { + /* return success of awaiting. This may be + * returned from any function + */ + return (PXE_AWAIT_COMPLETED); + } + + /* if await was not completed, continue waiting */ + return (PXE_AWAIT_CONTINUE); + break; + + case PXE_AWAIT_END: + /* this called if await is ended without any result */ + default: + break; + } + + return (PXE_AWAIT_OK); + } + + /* end of example */ + + So, wait data used for providing and receiving data while + awaiting. pxe_await() performs unified working with code, needed for + waiting of incoming packets. + +macro definitions: + +TIME_DELTA_MS - delay between iterations during awaitng. At each + iteration are checked: + * receiving of new packet. If received - awaiting + function with PXE_AWAIT_NEWPACKETS function is called. + * try timeout. if timeout exceeds maximum timeout - + awaiting function with PXE_AWAIT_FINISHTRY and + PXE_AWAIT_STARTTRY flags sequentially are called. + * try count. if try count exceeds maximum - awaiting + function with PXE_AWAIT_ENDED flag is called. This + means that await failed. + Default: 1 + +TIME_DELTA - default: 1000, same as TIME_DELTA_MS, but in ticks + for delay. + + +3.3.3 pxe_buffer module +------------------------ + + This module provides reading and writing of cyclic buffers. + It's not used directly by user code. + +macro definitions: + +PXE_POOL_SLOTS - if defined, then statical allocation of buffers is + used. Otherwise buffers are allocated at run-time from + heap with pxe_alloc() function. Current statical + allocation algorithm is simple and square, there are + two big buffers data storages divided in slots (by + default 2). + Each slot has size equal to + PXE_DEFAULT_RECV_BUFSIZE or PXE_DEFAULT_SEND_BUFSIZE. + Depending on requested size in pxe_buffer_alloc() + function data allocated from one of stoarge and + related slot marked busy. When pxe_buffer_free() called, + slot marked as free. + Default: undefined + +PXE_DEFAULT_RECV_BUFSIZE - size of receiving buffer. Default: 16392 + +PXE_DEFAULT_SEND_BUFSIZE - size of sending buffer. Default: 4096 + + +3.3.4 pxe_connection module +---------------------------- + + This module is one of TCP related modules. It implements + connection entity. TCP connection is logical structure, that have + needed by TCP protocol counters and states. + User code is not directly works with this module. + +macro definitions: + +PXE_MAX_TCP_CONNECTIONS - how much simultaneous connections may be. + + +functions: + +void pxe_connection_stats() + - returns connections statistics. Available if PXE_MORE macro is + defined. + + +3.3.5 pxe_core module +---------------------- + + This module performs lowlevel work with PXE API: initialisation, + receiving/sending of packets, provides information functions. + In most cases, user code doesn't uses this module directly. + +macro definitions: + +PXE_BUFFER_SIZE - size of core buffers, used in PXE API calling, + Default: 4096 + +PXE_CORE_STATIC_BUFFERS - if defined, core buffers are allocated statically. + Otherwise they are allocated in heap. Default: defined + +functions: + +int pxe_core_recv_packets() + - recieves all packets waiting in incoming queue of NIC, and calls + appropriate protocols if needed + + +void pxe_core_register(uint8_t ip_proto, pxe_protocol_call proc) + - registers IP stack protocol, associates protocol number and handler. + +const MAC_ADDR *pxe_get_mymac() + - returns MAC of NIC, for which PXE API is used. + +const PXE_IPADDR *pxe_get_ip(uint8_t id) + - returns of stored IP, for provided id. + id may be: + PXE_IP_MY - NIC IP address + PXE_IP_NET - network adrress + PXE_IP_NETMASK - network mask + PXE_IP_NAMESERVER - nameserver to use in name resolving + PXE_IP_GATEWAY - default gateway + PXE_IP_BROADCAST - broadcast address + PXE_IP_SERVER - server from which loading of pxeboot + was performed + PXE_IP_WWW - IP address of http-server + PXE_IP_ROOT - IP adddress of server, where root + file system is situated. + +void pxe_set_ip(uint8_t id, const PXE_IPADDR *ip) + - sets value by it's id. + +time_t pxe_get_secs() + - returns time in seconds. Used in timeout and resend checking. + +types: + +typedef int (*pxe_protocol_call)(PXE_PACKET *pack, uint8_t function) + - protocol callback function type + + +3.3.6. pxe_dhcp module +----------------------- + + This module implements simple DHCP client, used to obtain + gateway, nameserver and other information. + + +macro definitions: + +PXE_BOOTP_USE_LIBSTAND - use bootp() function provided by libstand instead + of own DHCP client. NOTE: bootp() doesn't set nameip (nameserver ip + structure), thus DNS resolving will be impossible. Default: undefined + + NOTE: to use bootp(), also UDP_DEFAULT_SOCKET macro must be defined. + + +functions: + +void pxe_dhcp_query(uint32_t xid) + - sends DHCPDISCOVER packet and sets core_ips, if gets reply. + + +3.3.6. pxe_dns module +---------------------- + + This module provides domain name resolving. Actually + A and CNAME resource records are supported. + +macro definitions: + +PXE_MAX_DNS_TIMEOUT - max time to wait DNS reply in milliseconds. + Default: 10 seconds + +PXE_MAX_DNS_TRYS - how many times to try to resend request, + if there is no reply. Default: 3 + +PXE_DNS_MAX_PACKET_SIZE - maximum UDP packet size in bytes. Default: 512. + This DNS client doesn't support TCP for resolving. + +functions: + +const PXE_IPADDR *pxe_gethostbyname(char *name) + - returns IP, if resolved, for provided domain name. + +uint32_t pxe_convert_ipstr(char *str) + - converts string value of ipv4 to uint32_t value. + + +3.3.8. pxe_filter module +------------------------- + + This module is not supposed to be used by user code directly. + It implements filtering of incoming IP packets. It's used by UDP and + TCP modules for sorting packets in appropriate socket. + Module provides functions for adding and removing filters. + Each filter contains source/destination ip:port definition and masks + for all of them. Usage of masks gives opportunity to recieve data + from subnet, or subset of ports. + +functions: + +void pxe_filter_init() + - inits filter module structures such as list of free filter entries. + +void pxe_filter_stats() + - show active filters information. Used for debugging. Available if + PXE_MORE macro defined. + + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Wed Jan 16 03:59:43 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9260668A; Wed, 16 Jan 2013 03:59:43 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 6D4B93DD; Wed, 16 Jan 2013 03:59:43 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0G3xhas066525; Wed, 16 Jan 2013 03:59:43 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0G3xhLO066524; Wed, 16 Jan 2013 03:59:43 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201301160359.r0G3xhLO066524@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Wed, 16 Jan 2013 03:59:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245488 - user/ae/inet6 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jan 2013 03:59:43 -0000 Author: ae Date: Wed Jan 16 03:59:42 2013 New Revision: 245488 URL: http://svnweb.freebsd.org/changeset/base/245488 Log: Prepare a testbed for my inet6 changes. Added: - copied from r245487, head/ Directory Properties: user/ae/inet6/ (props changed) From owner-svn-src-user@FreeBSD.ORG Wed Jan 16 04:35:36 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 487E2B6D; Wed, 16 Jan 2013 04:35:36 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 2C99872D; Wed, 16 Jan 2013 04:35:36 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0G4ZaJR078292; Wed, 16 Jan 2013 04:35:36 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0G4ZZDE078289; Wed, 16 Jan 2013 04:35:35 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201301160435.r0G4ZZDE078289@svn.freebsd.org> From: Sean Bruno Date: Wed, 16 Jan 2013 04:35:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245489 - user/sbruno/pxestuff/sys/boot/i386/loader X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jan 2013 04:35:36 -0000 Author: sbruno Date: Wed Jan 16 04:35:35 2013 New Revision: 245489 URL: http://svnweb.freebsd.org/changeset/base/245489 Log: Merge last changes from pxe_http tree into the head version of /boot looks like I've got some include files problems, clang doesn't handle this part of the tree yet and I've found unsupported clang bits? Note: doesn't compile yet, try again after I get some sleep Modified: user/sbruno/pxestuff/sys/boot/i386/loader/Makefile user/sbruno/pxestuff/sys/boot/i386/loader/conf.c user/sbruno/pxestuff/sys/boot/i386/loader/main.c Modified: user/sbruno/pxestuff/sys/boot/i386/loader/Makefile ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/loader/Makefile Wed Jan 16 03:59:42 2013 (r245488) +++ user/sbruno/pxestuff/sys/boot/i386/loader/Makefile Wed Jan 16 04:35:35 2013 (r245489) @@ -26,6 +26,8 @@ LIBZFSBOOT= ${.OBJDIR}/../../zfs/libzfsb # Enable PXE TFTP or NFS support, not both. .if defined(LOADER_TFTP_SUPPORT) CFLAGS+= -DLOADER_TFTP_SUPPORT +.elif defined(LOADER_HTTP_SUPPORT) +CFLAGS+= -DLOADER_HTTP_SUPPORT .else CFLAGS+= -DLOADER_NFS_SUPPORT .endif @@ -37,6 +39,9 @@ HAVE_BCACHE= yes HAVE_PNP= yes HAVE_ISABUS= yes +# Enable more pxe_http functions +#CFLAGS+= -DPXE_MORE + .if ${MK_FORTH} != "no" # Enable BootForth BOOT_FORTH= yes @@ -66,12 +71,15 @@ CFLAGS+= -Wall LDFLAGS= -static -Ttext 0x0 # i386 standalone support library -LIBI386= ${.OBJDIR}/../libi386/libi386.a +LIBI386= ${.OBJDIR}/../libi386/libi386.a ${.OBJDIR}/../pxehttp/libpxe_http.a CFLAGS+= -I${.CURDIR}/.. # BTX components CFLAGS+= -I${.CURDIR}/../btx/lib +# PXE HTTP components +CFLAGS+= -I$(.CURDIR)/../pxe_http + # Debug me! #CFLAGS+= -g #LDFLAGS+= -g Modified: user/sbruno/pxestuff/sys/boot/i386/loader/conf.c ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/loader/conf.c Wed Jan 16 03:59:42 2013 (r245488) +++ user/sbruno/pxestuff/sys/boot/i386/loader/conf.c Wed Jan 16 04:35:35 2013 (r245489) @@ -45,6 +45,11 @@ __FBSDID("$FreeBSD$"); * XXX as libi386 and biosboot merge, some of these can become linker sets. */ +#ifdef LOADER_HTTP_SUPORT +#undef LOADER_NFS_SUPPORT +#undef LOADER_TFTP_SUPPO +#endif + #if defined(LOADER_NFS_SUPPORT) && defined(LOADER_TFTP_SUPPORT) #error "Cannot have both tftp and nfs support yet." #endif @@ -57,7 +62,8 @@ extern struct devsw fwohci; struct devsw *devsw[] = { &bioscd, &biosdisk, -#if defined(LOADER_NFS_SUPPORT) || defined(LOADER_TFTP_SUPPORT) +#if defined(LOADER_NFS_SUPPORT) || defined(LOADER_TFTP_SUPPORT) || \ + defined(LOADER_HTTP_SUPPORT) &pxedisk, #endif #if defined(LOADER_FIREWIRE_SUPPORT) @@ -69,14 +75,32 @@ struct devsw *devsw[] = { NULL }; +#if defined(LOADER_HTTP_SUPPORT) +/* free as much as possible memory, by removing unused by PXE filesystems */ +#undef LOADER_EXT2_SUPPORT +#undef LOADER_DOS_SUPPORT +#undef LOADER_CD9660_SUPPORT +#undef LOADER_SPLITFS_SUPPORT +#undef LOADER_NFS_SUPPORT +#undef LOADER_TFTP_SUPPORT +#else +#define LOADER_NFS_SUPPORT +#endif + struct fs_ops *file_system[] = { #if defined(LOADER_ZFS_SUPPORT) &zfs_fsops, #endif &ufs_fsops, +#if defined(LOADER_EXT2_SUPPORT) &ext2fs_fsops, +#endif +#if defined(LOADER_DOS_SUPPORT) &dosfs_fsops, +#endif +#if defined(LOADER_CD9660_SUPPORT) &cd9660_fsops, +#endif #if defined(LOADER_NANDFS_SUPPORT) &nandfs_fsops, #endif @@ -95,6 +119,9 @@ struct fs_ops *file_system[] = { #ifdef LOADER_TFTP_SUPPORT &tftp_fsops, #endif +#ifdef LOADER_HTTP_SUPPORT + &http_fsops, +#endif NULL }; Modified: user/sbruno/pxestuff/sys/boot/i386/loader/main.c ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/loader/main.c Wed Jan 16 03:59:42 2013 (r245488) +++ user/sbruno/pxestuff/sys/boot/i386/loader/main.c Wed Jan 16 04:35:35 2013 (r245489) @@ -49,6 +49,19 @@ __FBSDID("$FreeBSD$"); #include "../zfs/libzfs.h" #endif +#ifdef PXE_MORE +#include "pxe_arp.h" +#include "pxe_connection.h" +#include "pxe_dns.h" +#include "pxe_filter.h" +#include "pxe_http.h" +#include "pxe_httpls.h" +#include "pxe_icmp.h" +#include "pxe_ip.h" +#include "pxe_sock.h" +#include "pxe_tcp.h" +#include "pxe_udp.h" +#endif CTASSERT(sizeof(struct bootargs) == BOOTARGS_SIZE); CTASSERT(offsetof(struct bootargs, bootinfo) == BA_BOOTINFO); CTASSERT(offsetof(struct bootargs, bootflags) == BA_BOOTFLAGS); @@ -101,7 +114,8 @@ main(void) bios_getmem(); #if defined(LOADER_BZIP2_SUPPORT) || defined(LOADER_FIREWIRE_SUPPORT) || \ - defined(LOADER_GPT_SUPPORT) || defined(LOADER_ZFS_SUPPORT) + defined(LOADER_GPT_SUPPORT) || defined(LOADER_ZFS_SUPPORT) || \ + defined(LOADER_HTTP_SUPPORT) if (high_heap_size > 0) { heap_top = PTOV(high_heap_base + high_heap_size); heap_bottom = PTOV(high_heap_base); @@ -368,6 +382,290 @@ isa_outb(int port, int value) outb(port, value); } +#ifdef PXE_MORE +/* added for pxe_http */ +static int +command_route(int argc, char *argv[]) +{ + PXE_IPADDR net; + PXE_IPADDR gw; + + if (argc < 2) { + printf("use: route add|del|print [default|net_addr gw_addr] \n"); + return (CMD_OK); + } + + if (!strcmp(argv[1], "print")) { + pxe_ip_route_stat(); + return (CMD_OK); + } + + if (argc < 4) { + printf("use: route add|del default|net_addr gw_addr\n"); + return (CMD_OK); + } + + if ( (strcmp(argv[1], "add") != 0) && (strcmp(argv[1], "del") != 0)) + return (CMD_OK); + + if (!strcmp(argv[2], "default")) { + + if (!strcmp(argv[1], "del")) { + printf("Cannot delete default gateway.\n"); + return (CMD_OK); + } + + gw.ip = pxe_convert_ipstr(argv[3]); + + pxe_ip_route_default(&gw); + + return (CMD_OK); + } + + gw.ip = pxe_convert_ipstr(argv[3]); + net.ip = pxe_convert_ipstr(argv[2]); + + if (!strcmp(argv[1], "add")) { + pxe_ip_route_add(&net, pxe_ip_get_netmask(&net), &gw); + return (CMD_OK); + } + + pxe_ip_route_del(&net, pxe_ip_get_netmask(&net), &gw); + + return (CMD_OK); +} + +static int +command_arp(int argc, char *argv[]) +{ + PXE_IPADDR *ip; + + if (argc > 1) { + + if (strcmp(argv[1], "stats") != 0) + ip = pxe_gethostbyname(argv[1]); + else { + pxe_arp_stats(); + return (CMD_OK); + } + + } else { + printf("use: arp ip4_address|stats\n"); + return (CMD_OK); + } + + printf("searching ip: %s\n", (ip != NULL) ? inet_ntoa(ip->ip) : "?"); + + const uint8_t* mac = (const uint8_t *)pxe_arp_ip4mac(ip); + + if (mac != NULL) + printf("MAC: %6D\n", mac, ":"); + else + printf("MAC search failed.\n"); + + return (CMD_OK); +} + +static int +command_ping(int argc, char *argv[]) +{ + PXE_IPADDR *ip = NULL; + + pxe_icmp_init(); + + if (argc > 1) + ip = pxe_gethostbyname(argv[1]); + else { + printf("use: ping ip4_address\n"); + return (CMD_OK); + } + + pxe_ping(ip, 5, 1); + + return (CMD_OK); +} + +static int +command_await() +{ + + while (1) { + if (!pxe_core_recv_packets()) { + twiddle(); + delay(10000); + } + } + + return (0); +} + +static int +command_sock(int argc, char *argv[]) +{ + if (argc < 2) { + printf("use: socket stats|tcptest\n"); + return (CMD_OK); + } + + if (!strcmp(argv[1], "stats")) { + pxe_sock_stats(); + return (CMD_OK); + } + + return (CMD_OK); +} + +static int +command_resolve(int argc, char *argv[]) +{ + if (argc < 2) { + printf("use: resolve dns_name\n"); + return (CMD_OK); + } + + PXE_IPADDR *ip; + + char* name = argv[1]; + + ip = pxe_gethostbyname(name); + + if ( (ip == NULL) || (ip->ip == 0)) + printf("failed to resolve domain %s\n", name); + else + printf("%s resolved as %s\n", name, inet_ntoa(ip->ip)); + + return (CMD_OK); +} + +static int +command_ns(int argc, char *argv[]) +{ + PXE_IPADDR *ip; + + if (argc == 1) { + ip = pxe_get_ip32(PXE_IP_NAMESERVER); + printf("primary nameserver: %s\n", inet_ntoa(ip->ip)); + return (CMD_OK); + } + + PXE_IPADDR addr; + + addr.ip = pxe_convert_ipstr(argv[1]); + + if (addr.ip != 0) + pxe_set_ip32(PXE_IP_NAMESERVER, &addr); + else + printf("Syntax error in ip address.\n"); + + return (CMD_OK); +} + +static int +command_fetch(int argc, char *argv[]) +{ + if (argc == 1) { + printf("usage: fetch server/path/to/file.ext\n"); + return (CMD_OK); + } + + char *server_name = argv[1]; + char *filename = server_name; + + while (*filename) { + if (*filename == '/') { + *filename = '\0'; + ++filename; + break; + } + ++filename; + } + + /* retrieve all file */ + pxe_fetch(server_name, filename, 0LL, 0L); + + return (CMD_OK); +} + +static int +command_ls(int argc, char *argv[]) +{ + + if (argc == 1) { + printf("usage: ls /path/to/dir\n"); + return (CMD_OK); + } + + int fd = open(argv[1], O_RDONLY); + + if (fd == -1) + return (CMD_OK); + + http_parse_index(fd); + + close(fd); + + return (CMD_OK); +} + +COMMAND_SET(pxe, "pxe", "pxe test module", command_pxe); + +static int +command_pxe(int argc, char *argv[]) +{ + if (argc<2) { + printf("PXE test module (built at %s %s)\n", __DATE__, __TIME__); + printf(" use: pxe arp|await|connections|fetch|filters|\n" + "\tping|resolve|route|socket\n"); + return (CMD_OK); + } + + if (!strcmp(argv[1], "arp")) + return command_arp(argc - 1, &argv[1]); + + if (!strcmp(argv[1], "ping")) + return command_ping(argc - 1, &argv[1]); + + if (!strcmp(argv[1], "route")) + return command_route(argc - 1, &argv[1]); + + if (!strcmp(argv[1], "filters")) { + pxe_filter_stats(); + return (CMD_OK); + } + + if (!strcmp(argv[1], "socket")) + return command_sock(argc - 1, &argv[1]); + + if (!strcmp(argv[1], "resolve")) + return command_resolve(argc - 1, &argv[1]); + + if (!strcmp(argv[1], "ns")) + return command_ns(argc - 1, &argv[1]); + + + if (!strcmp(argv[1], "await")) + return command_await(); + + if (!strcmp(argv[1], "connections")) { + pxe_connection_stats(); + return (CMD_OK); + } + + if (!strcmp(argv[1], "fetch")) { + return command_fetch(argc - 1, &argv[1]); + } + + if (!strcmp(argv[1], "ls")) { + return command_ls(argc - 1, &argv[1]); + } + + printf("unknown pxe command '%s'\n", argv[1]); + + return (CMD_OK); +} +/* pxe_http add end */ +#endif + #ifdef LOADER_ZFS_SUPPORT static void i386_zfs_probe(void) From owner-svn-src-user@FreeBSD.ORG Wed Jan 16 22:06:01 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 66D298BC; Wed, 16 Jan 2013 22:06:01 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 29EB612B; Wed, 16 Jan 2013 22:06:01 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0GM61Fl077610; Wed, 16 Jan 2013 22:06:01 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0GM60UM077605; Wed, 16 Jan 2013 22:06:00 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201301162206.r0GM60UM077605@svn.freebsd.org> From: Sean Bruno Date: Wed, 16 Jan 2013 22:06:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245509 - in user/sbruno/pxestuff/sys/boot/i386: libi386 loader X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jan 2013 22:06:01 -0000 Author: sbruno Date: Wed Jan 16 22:06:00 2013 New Revision: 245509 URL: http://svnweb.freebsd.org/changeset/base/245509 Log: Now we come down to the linker issues between whatever functions are in "libhttp_pxe" and libstand. Things compile now, but still need symbol resolution. Modified: user/sbruno/pxestuff/sys/boot/i386/libi386/pxe.h user/sbruno/pxestuff/sys/boot/i386/loader/Makefile user/sbruno/pxestuff/sys/boot/i386/loader/conf.c Modified: user/sbruno/pxestuff/sys/boot/i386/libi386/pxe.h ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/libi386/pxe.h Wed Jan 16 21:52:31 2013 (r245508) +++ user/sbruno/pxestuff/sys/boot/i386/libi386/pxe.h Wed Jan 16 22:06:00 2013 (r245509) @@ -38,6 +38,8 @@ * It's for your own good. :) */ +#ifndef PXEHEADERINCLUDES +#define PXEHEADERINCLUDES /* It seems that intel didn't think about ABI, * either that or 16bit ABI != 32bit ABI (which seems reasonable) * I have to thank Intel for the hair loss I incurred trying to figure @@ -511,3 +513,4 @@ typedef struct { typedef struct { PXENV_STATUS_t Status; } PACKED t_PXENV_STOP_BASE; +#endif Modified: user/sbruno/pxestuff/sys/boot/i386/loader/Makefile ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/loader/Makefile Wed Jan 16 21:52:31 2013 (r245508) +++ user/sbruno/pxestuff/sys/boot/i386/loader/Makefile Wed Jan 16 22:06:00 2013 (r245509) @@ -78,7 +78,7 @@ CFLAGS+= -I${.CURDIR}/.. CFLAGS+= -I${.CURDIR}/../btx/lib # PXE HTTP components -CFLAGS+= -I$(.CURDIR)/../pxe_http +CFLAGS+= -I$(.CURDIR)/../pxehttp # Debug me! #CFLAGS+= -g Modified: user/sbruno/pxestuff/sys/boot/i386/loader/conf.c ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/loader/conf.c Wed Jan 16 21:52:31 2013 (r245508) +++ user/sbruno/pxestuff/sys/boot/i386/loader/conf.c Wed Jan 16 22:06:00 2013 (r245509) @@ -33,6 +33,9 @@ __FBSDID("$FreeBSD$"); #if defined(LOADER_ZFS_SUPPORT) #include "../zfs/libzfs.h" #endif +#if defined(LOADER_HTTP_SUPPORT) +#include "pxehttp/httpfs.h" +#endif /* * We could use linker sets for some or all of these, but @@ -47,7 +50,7 @@ __FBSDID("$FreeBSD$"); #ifdef LOADER_HTTP_SUPORT #undef LOADER_NFS_SUPPORT -#undef LOADER_TFTP_SUPPO +#undef LOADER_TFTP_SUPPORT #endif #if defined(LOADER_NFS_SUPPORT) && defined(LOADER_TFTP_SUPPORT) From owner-svn-src-user@FreeBSD.ORG Thu Jan 17 01:18:25 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id BCB36B8A; Thu, 17 Jan 2013 01:18:25 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 9F140D89; Thu, 17 Jan 2013 01:18:25 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0H1IPot035321; Thu, 17 Jan 2013 01:18:25 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0H1IOaI035314; Thu, 17 Jan 2013 01:18:24 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201301170118.r0H1IOaI035314@svn.freebsd.org> From: Sean Bruno Date: Thu, 17 Jan 2013 01:18:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245523 - in user/sbruno/pxestuff/sys/boot/i386: btx/lib pxehttp X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jan 2013 01:18:25 -0000 Author: sbruno Date: Thu Jan 17 01:18:24 2013 New Revision: 245523 URL: http://svnweb.freebsd.org/changeset/base/245523 Log: Rename conflicting function name/routines to not conflict with existing libbtx/i386 functions. Modified: user/sbruno/pxestuff/sys/boot/i386/btx/lib/btxv86.h user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_core.c user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_isr.S user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_isr.h Modified: user/sbruno/pxestuff/sys/boot/i386/btx/lib/btxv86.h ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/btx/lib/btxv86.h Thu Jan 17 00:50:25 2013 (r245522) +++ user/sbruno/pxestuff/sys/boot/i386/btx/lib/btxv86.h Thu Jan 17 01:18:24 2013 (r245523) @@ -64,9 +64,4 @@ extern u_int32_t __args; void __exit(int) __attribute__((__noreturn__)); void __exec(caddr_t, ...); -/* - * Installs interrupt handler function for interrupt int_num. - * caddr_t - in userspace. - */ -void __isr_install(caddr_t isr, uint16_t int_num); #endif /* !_BTXV86_H_ */ Modified: user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_core.c ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_core.c Thu Jan 17 00:50:25 2013 (r245522) +++ user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_core.c Thu Jan 17 01:18:24 2013 (r245523) @@ -431,7 +431,7 @@ pxe_core_install_isr() pxe_memset(&v86, 0, sizeof(v86)); v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS; - v86.addr = (VTOPSEG(__isr_install) << 16) | VTOPOFF(__isr_install); + v86.addr = (VTOPSEG(__pxe_isr_install) << 16) | VTOPOFF(__pxe_isr_install); v86.eax = int_num; v86.ebx = VTOPSEG(__pxe_isr); v86.edx = VTOPOFF(__pxe_isr); @@ -490,7 +490,7 @@ pxe_core_remove_isr() pxe_memset(&v86, 0, sizeof(v86)); v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS; - v86.addr = (VTOPSEG(__isr_install) << 16) | VTOPOFF(__isr_install); + v86.addr = (VTOPSEG(__pxe_isr_install) << 16) | VTOPOFF(__pxe_isr_install); uint8_t int_num = (__pxe_nic_irq < 8) ? __pxe_nic_irq + 0x08 : __pxe_nic_irq + 0x68; @@ -1104,19 +1104,3 @@ pxe_set_ip(uint8_t id, const PXE_IPADDR pxe_memcpy(new_ip, &core_ips[id], sizeof(PXE_IPADDR)); } } - -/* getsecs() - returns time in seconds - * in: - * none - * out: - * elapsed time in seconds - */ -time_t -getsecs() -{ - time_t secs = 0; - - time(&secs); - - return (secs); -} Modified: user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_isr.S ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_isr.S Thu Jan 17 00:50:25 2013 (r245522) +++ user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_isr.S Thu Jan 17 01:18:24 2013 (r245523) @@ -34,8 +34,8 @@ .globl __pxe_entry_off, __pxe_entry_seg .globl __pxe_entry_off2, __pxe_entry_seg2 .globl __pxe_call - .globl __isr_install - .globl __isr_remove + .globl __pxe_isr_install + .globl __pxe_isr_remove .globl __pxe_isr .globl __chained_irq_off .globl __chained_irq_seg @@ -287,7 +287,7 @@ pxe_isr.2: .byte 0xcb /* - * __isr_install() - installs interrupt handler for provided IRQ, + * __pxe_isr_install() - installs interrupt handler for provided IRQ, * saves previous ("chained") handler * in: * AX - interrupt number (not IRQ) @@ -297,7 +297,7 @@ pxe_isr.2: * BX - chained ISR segment * DX - chained ISR offset */ -__isr_install: +__pxe_isr_install: cli # no interrupts pushl %edi # saving affected registers pushw %ds # @@ -322,7 +322,7 @@ __isr_install: .byte 0xcb # back to vm86 -/* __isr_remove() - uninstalls ISR +/* __pxe_isr_remove() - uninstalls ISR * Adopted from Intel PXE SDK * removes interrupt handler for provided IRQ, restores previous handler * in: @@ -331,7 +331,7 @@ __isr_install: * out: * none */ -__isr_remove: pushf +__pxe_isr_remove: pushf pushl %ebx shlw $2, %bx # calculating offset of @@ -341,7 +341,7 @@ __isr_remove: pushf movw %es:(%bx), %ax # get offset to current handler -isr_remove.3: #movl chained_irq_off, %eax # getting old chained handler +pxe_isr_remove.3: #movl chained_irq_off, %eax # getting old chained handler #movl %eax, %es:(%bx) # restore it /* @@ -350,7 +350,7 @@ isr_remove.3: #movl chained_irq_off, % * call unmask_int # unmasking **/ -isr_remove.fin: +pxe_isr_remove.fin: # movl $0x0, chained_irq_off popl %ebx popf Modified: user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_isr.h ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_isr.h Thu Jan 17 00:50:25 2013 (r245522) +++ user/sbruno/pxestuff/sys/boot/i386/pxehttp/pxe_isr.h Thu Jan 17 01:18:24 2013 (r245523) @@ -54,7 +54,7 @@ extern void __pxe_call(void); /* PXE API extern void __pxe_isr(void); /* PXE API call */ extern void __mask_irq(void); /* masks irq */ -extern void __isr_install(void); /* installs handler for interrupt */ +extern void __pxe_isr_install(void);/* installs handler for interrupt */ extern void __isr_remove(void); /* remove handler, ! not working ! now */ extern void __mem_copy(void); /* copies memory in vm86 mode */ From owner-svn-src-user@FreeBSD.ORG Thu Jan 17 01:19:14 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id F11A9CA8; Thu, 17 Jan 2013 01:19:14 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C0625D8F; Thu, 17 Jan 2013 01:19:14 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0H1JEvZ035458; Thu, 17 Jan 2013 01:19:14 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0H1JEVa035456; Thu, 17 Jan 2013 01:19:14 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201301170119.r0H1JEVa035456@svn.freebsd.org> From: Sean Bruno Date: Thu, 17 Jan 2013 01:19:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245524 - user/sbruno/pxestuff/lib/libstand X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jan 2013 01:19:15 -0000 Author: sbruno Date: Thu Jan 17 01:19:14 2013 New Revision: 245524 URL: http://svnweb.freebsd.org/changeset/base/245524 Log: Add snprintf() for now to libstand. I don't know if I actually want this in base, but let's just see what its used for and how importand this is. Modified: user/sbruno/pxestuff/lib/libstand/printf.c user/sbruno/pxestuff/lib/libstand/stand.h Modified: user/sbruno/pxestuff/lib/libstand/printf.c ============================================================================== --- user/sbruno/pxestuff/lib/libstand/printf.c Thu Jan 17 01:18:24 2013 (r245523) +++ user/sbruno/pxestuff/lib/libstand/printf.c Thu Jan 17 01:19:14 2013 (r245524) @@ -91,6 +91,31 @@ sprintf(char *buf, const char *cfmt, ... return retval; } +int +snprintf(char *buf, size_t size, const char *cfmt, ...) +{ + int retval; + va_list ap; + size_t maxsize = (size > 1) ? size - 1 : 0; + + if (maxsize == 0) { + buf[0] = '\0'; + return (0); + } + + va_start(ap, cfmt); + retval = kvprintf(cfmt, NULL, (void *)buf, 10, ap); + + if (retval < maxsize) + buf[retval] = '\0'; + else + buf[maxsize] = '\0'; + + va_end(ap); + + return (retval); +} + void vsprintf(char *buf, const char *cfmt, va_list ap) { Modified: user/sbruno/pxestuff/lib/libstand/stand.h ============================================================================== --- user/sbruno/pxestuff/lib/libstand/stand.h Thu Jan 17 01:18:24 2013 (r245523) +++ user/sbruno/pxestuff/lib/libstand/stand.h Thu Jan 17 01:19:14 2013 (r245524) @@ -238,6 +238,7 @@ extern void mallocstats(void); extern int printf(const char *fmt, ...) __printflike(1, 2); extern void vprintf(const char *fmt, __va_list); extern int sprintf(char *buf, const char *cfmt, ...) __printflike(2, 3); +extern int snprintf(char *buf, size_t size, const char *cfmt, ...) __printflike(3, 4); extern void vsprintf(char *buf, const char *cfmt, __va_list); extern void twiddle(void); From owner-svn-src-user@FreeBSD.ORG Thu Jan 17 02:30:32 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id BABE6958; Thu, 17 Jan 2013 02:30:32 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A2F9D175; Thu, 17 Jan 2013 02:30:32 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0H2UWsR056721; Thu, 17 Jan 2013 02:30:32 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0H2UWLd056719; Thu, 17 Jan 2013 02:30:32 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201301170230.r0H2UWLd056719@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Thu, 17 Jan 2013 02:30:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245529 - user/ae/inet6/sys/netinet6 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jan 2013 02:30:32 -0000 Author: ae Date: Thu Jan 17 02:30:32 2013 New Revision: 245529 URL: http://svnweb.freebsd.org/changeset/base/245529 Log: Use M_ZERO flag instead of explicit bzero call after malloc. Modified: user/ae/inet6/sys/netinet6/in6.c Modified: user/ae/inet6/sys/netinet6/in6.c ============================================================================== --- user/ae/inet6/sys/netinet6/in6.c Thu Jan 17 02:23:40 2013 (r245528) +++ user/ae/inet6/sys/netinet6/in6.c Thu Jan 17 02:30:32 2013 (r245529) @@ -2703,17 +2703,13 @@ in6_domifattach(struct ifnet *ifp) { struct in6_ifextra *ext; - ext = (struct in6_ifextra *)malloc(sizeof(*ext), M_IFADDR, M_WAITOK); - bzero(ext, sizeof(*ext)); - - ext->in6_ifstat = (struct in6_ifstat *)malloc(sizeof(struct in6_ifstat), - M_IFADDR, M_WAITOK); - bzero(ext->in6_ifstat, sizeof(*ext->in6_ifstat)); - + ext = (struct in6_ifextra *)malloc(sizeof(*ext), M_IFADDR, + M_WAITOK | M_ZERO); + ext->in6_ifstat = (struct in6_ifstat *)malloc( + sizeof(struct in6_ifstat), M_IFADDR, M_WAITOK | M_ZERO); ext->icmp6_ifstat = (struct icmp6_ifstat *)malloc(sizeof(struct icmp6_ifstat), - M_IFADDR, M_WAITOK); - bzero(ext->icmp6_ifstat, sizeof(*ext->icmp6_ifstat)); + M_IFADDR, M_WAITOK | M_ZERO); ext->nd_ifinfo = nd6_ifattach(ifp); ext->scope6_id = scope6_ifattach(ifp); @@ -2723,10 +2719,9 @@ in6_domifattach(struct ifnet *ifp) ext->lltable->llt_lookup = in6_lltable_lookup; ext->lltable->llt_dump = in6_lltable_dump; } - ext->mld_ifinfo = mld_domifattach(ifp); - return ext; + return (ext); } void From owner-svn-src-user@FreeBSD.ORG Thu Jan 17 03:18:54 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 6B37F36D; Thu, 17 Jan 2013 03:18:54 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 2DBAC670; Thu, 17 Jan 2013 03:18:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0H3IsFa072137; Thu, 17 Jan 2013 03:18:54 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0H3IrA4072135; Thu, 17 Jan 2013 03:18:53 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201301170318.r0H3IrA4072135@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Thu, 17 Jan 2013 03:18:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245531 - user/ae/inet6/sys/netinet6 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jan 2013 03:18:54 -0000 Author: ae Date: Thu Jan 17 03:18:53 2013 New Revision: 245531 URL: http://svnweb.freebsd.org/changeset/base/245531 Log: Add in6_getlinkzone() function. It returns zone id for the link-local scope (currently it is equal to the interface's if_index). Also, use M_ZERO flag in malloc(). Modified: user/ae/inet6/sys/netinet6/scope6.c user/ae/inet6/sys/netinet6/scope6_var.h Modified: user/ae/inet6/sys/netinet6/scope6.c ============================================================================== --- user/ae/inet6/sys/netinet6/scope6.c Thu Jan 17 02:42:08 2013 (r245530) +++ user/ae/inet6/sys/netinet6/scope6.c Thu Jan 17 03:18:53 2013 (r245531) @@ -95,8 +95,8 @@ scope6_ifattach(struct ifnet *ifp) { struct scope6_id *sid; - sid = (struct scope6_id *)malloc(sizeof(*sid), M_IFADDR, M_WAITOK); - bzero(sid, sizeof(*sid)); + sid = (struct scope6_id *)malloc(sizeof(*sid), M_IFADDR, + M_WAITOK | M_ZERO); /* * XXX: IPV6_ADDR_SCOPE_xxx macros are not standard. @@ -104,13 +104,8 @@ scope6_ifattach(struct ifnet *ifp) */ sid->s6id_list[IPV6_ADDR_SCOPE_INTFACELOCAL] = ifp->if_index; sid->s6id_list[IPV6_ADDR_SCOPE_LINKLOCAL] = ifp->if_index; -#ifdef MULTI_SCOPE - /* by default, we don't care about scope boundary for these scopes. */ - sid->s6id_list[IPV6_ADDR_SCOPE_SITELOCAL] = 1; - sid->s6id_list[IPV6_ADDR_SCOPE_ORGLOCAL] = 1; -#endif - return sid; + return (sid); } void @@ -477,3 +472,14 @@ in6_getscope(struct in6_addr *in6) return (0); } + +/* + * Return zone id for the link-local scope. + */ +uint32_t +in6_getlinkzone(const struct ifnet *ifp) +{ + + return (ifp->if_index); +} + Modified: user/ae/inet6/sys/netinet6/scope6_var.h ============================================================================== --- user/ae/inet6/sys/netinet6/scope6_var.h Thu Jan 17 02:42:08 2013 (r245530) +++ user/ae/inet6/sys/netinet6/scope6_var.h Thu Jan 17 03:18:53 2013 (r245531) @@ -60,6 +60,7 @@ int sa6_recoverscope(struct sockaddr_in6 int in6_setscope(struct in6_addr *, struct ifnet *, u_int32_t *); int in6_clearscope(struct in6_addr *); uint16_t in6_getscope(struct in6_addr *); +uint32_t in6_getlinkzone(const struct ifnet *); #endif /* _KERNEL */ #endif /* _NETINET6_SCOPE6_VAR_H_ */ From owner-svn-src-user@FreeBSD.ORG Thu Jan 17 03:25:32 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 150E187C; Thu, 17 Jan 2013 03:25:32 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 083686D9; Thu, 17 Jan 2013 03:25:32 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0H3PVcb074899; Thu, 17 Jan 2013 03:25:31 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0H3PV0t074898; Thu, 17 Jan 2013 03:25:31 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201301170325.r0H3PV0t074898@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Thu, 17 Jan 2013 03:25:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245532 - user/ae/inet6/sys/netinet6 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jan 2013 03:25:32 -0000 Author: ae Date: Thu Jan 17 03:25:31 2013 New Revision: 245532 URL: http://svnweb.freebsd.org/changeset/base/245532 Log: Do not embed a scope zone id into link-local address, instead save it into sin6_scope_id field. Modified: user/ae/inet6/sys/netinet6/in6_ifattach.c Modified: user/ae/inet6/sys/netinet6/in6_ifattach.c ============================================================================== --- user/ae/inet6/sys/netinet6/in6_ifattach.c Thu Jan 17 03:18:53 2013 (r245531) +++ user/ae/inet6/sys/netinet6/in6_ifattach.c Thu Jan 17 03:25:31 2013 (r245532) @@ -480,8 +480,7 @@ in6_ifattach_linklocal(struct ifnet *ifp return (-1); } } - if (in6_setscope(&ifra.ifra_addr.sin6_addr, ifp, NULL)) - return (-1); + ifra.ifra_addr.sin6_scope_id = in6_getlinkzone(ifp); ifra.ifra_prefixmask.sin6_len = sizeof(struct sockaddr_in6); ifra.ifra_prefixmask.sin6_family = AF_INET6; From owner-svn-src-user@FreeBSD.ORG Thu Jan 17 03:27:54 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 56313D1D; Thu, 17 Jan 2013 03:27:54 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 32D7E709; Thu, 17 Jan 2013 03:27:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0H3Rsgk075444; Thu, 17 Jan 2013 03:27:54 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0H3RsFU075443; Thu, 17 Jan 2013 03:27:54 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201301170327.r0H3RsFU075443@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Thu, 17 Jan 2013 03:27:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245534 - user/ae/inet6/sys/netinet6 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jan 2013 03:27:54 -0000 Author: ae Date: Thu Jan 17 03:27:53 2013 New Revision: 245534 URL: http://svnweb.freebsd.org/changeset/base/245534 Log: The sin6_addr structure is already zeroed, no need to do it twice. Modified: user/ae/inet6/sys/netinet6/in6_ifattach.c Modified: user/ae/inet6/sys/netinet6/in6_ifattach.c ============================================================================== --- user/ae/inet6/sys/netinet6/in6_ifattach.c Thu Jan 17 03:27:08 2013 (r245533) +++ user/ae/inet6/sys/netinet6/in6_ifattach.c Thu Jan 17 03:27:53 2013 (r245534) @@ -469,9 +469,7 @@ in6_ifattach_linklocal(struct ifnet *ifp ifra.ifra_addr.sin6_family = AF_INET6; ifra.ifra_addr.sin6_len = sizeof(struct sockaddr_in6); ifra.ifra_addr.sin6_addr.s6_addr32[0] = htonl(0xfe800000); - ifra.ifra_addr.sin6_addr.s6_addr32[1] = 0; if ((ifp->if_flags & IFF_LOOPBACK) != 0) { - ifra.ifra_addr.sin6_addr.s6_addr32[2] = 0; ifra.ifra_addr.sin6_addr.s6_addr32[3] = htonl(1); } else { if (get_ifid(ifp, altifp, &ifra.ifra_addr.sin6_addr) != 0) { From owner-svn-src-user@FreeBSD.ORG Thu Jan 17 04:32:39 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 08861906; Thu, 17 Jan 2013 04:32:39 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id D9430256; Thu, 17 Jan 2013 04:32:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0H4WcBV095958; Thu, 17 Jan 2013 04:32:38 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0H4WcoK095956; Thu, 17 Jan 2013 04:32:38 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201301170432.r0H4WcoK095956@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Thu, 17 Jan 2013 04:32:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245537 - user/ae/inet6/sys/netinet6 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jan 2013 04:32:39 -0000 Author: ae Date: Thu Jan 17 04:32:38 2013 New Revision: 245537 URL: http://svnweb.freebsd.org/changeset/base/245537 Log: Remove redundant casts and use sizeof(object) instead of sizeof(typename). Suggested by: bde Modified: user/ae/inet6/sys/netinet6/in6.c user/ae/inet6/sys/netinet6/scope6.c Modified: user/ae/inet6/sys/netinet6/in6.c ============================================================================== --- user/ae/inet6/sys/netinet6/in6.c Thu Jan 17 04:20:53 2013 (r245536) +++ user/ae/inet6/sys/netinet6/in6.c Thu Jan 17 04:32:38 2013 (r245537) @@ -2703,13 +2703,11 @@ in6_domifattach(struct ifnet *ifp) { struct in6_ifextra *ext; - ext = (struct in6_ifextra *)malloc(sizeof(*ext), M_IFADDR, + ext = malloc(sizeof(*ext), M_IFADDR, M_WAITOK | M_ZERO); + ext->in6_ifstat = malloc(sizeof(*ext->in6_ifstat), M_IFADDR, + M_WAITOK | M_ZERO); + ext->icmp6_ifstat = malloc(sizeof(*ext->icmp6_ifstat), M_IFADDR, M_WAITOK | M_ZERO); - ext->in6_ifstat = (struct in6_ifstat *)malloc( - sizeof(struct in6_ifstat), M_IFADDR, M_WAITOK | M_ZERO); - ext->icmp6_ifstat = - (struct icmp6_ifstat *)malloc(sizeof(struct icmp6_ifstat), - M_IFADDR, M_WAITOK | M_ZERO); ext->nd_ifinfo = nd6_ifattach(ifp); ext->scope6_id = scope6_ifattach(ifp); Modified: user/ae/inet6/sys/netinet6/scope6.c ============================================================================== --- user/ae/inet6/sys/netinet6/scope6.c Thu Jan 17 04:20:53 2013 (r245536) +++ user/ae/inet6/sys/netinet6/scope6.c Thu Jan 17 04:32:38 2013 (r245537) @@ -95,9 +95,7 @@ scope6_ifattach(struct ifnet *ifp) { struct scope6_id *sid; - sid = (struct scope6_id *)malloc(sizeof(*sid), M_IFADDR, - M_WAITOK | M_ZERO); - + sid = malloc(sizeof(*sid), M_IFADDR, M_WAITOK | M_ZERO); /* * XXX: IPV6_ADDR_SCOPE_xxx macros are not standard. * Should we rather hardcode here? From owner-svn-src-user@FreeBSD.ORG Thu Jan 17 09:39:32 2013 Return-Path: Delivered-To: svn-src-user@FreeBSD.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 3C1A6CD0; Thu, 17 Jan 2013 09:39:32 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.69.10]) by mx1.freebsd.org (Postfix) with ESMTP id A78DDF8B; Thu, 17 Jan 2013 09:39:31 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.5/8.14.5) with ESMTP id r0H9dUAk001609; Thu, 17 Jan 2013 13:39:30 +0400 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.5/8.14.5/Submit) id r0H9dUWE001608; Thu, 17 Jan 2013 13:39:30 +0400 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Thu, 17 Jan 2013 13:39:30 +0400 From: Gleb Smirnoff To: "Andrey V. Elsukov" Subject: Re: svn commit: r245529 - user/ae/inet6/sys/netinet6 Message-ID: <20130117093930.GK96599@FreeBSD.org> References: <201301170230.r0H2UWLd056719@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <201301170230.r0H2UWLd056719@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: src-committers@FreeBSD.org, svn-src-user@FreeBSD.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jan 2013 09:39:32 -0000 On Thu, Jan 17, 2013 at 02:30:32AM +0000, Andrey V. Elsukov wrote: A> Author: ae A> Date: Thu Jan 17 02:30:32 2013 A> New Revision: 245529 A> URL: http://svnweb.freebsd.org/changeset/base/245529 A> A> Log: A> Use M_ZERO flag instead of explicit bzero call after malloc. A> A> Modified: A> user/ae/inet6/sys/netinet6/in6.c A> A> Modified: user/ae/inet6/sys/netinet6/in6.c A> ============================================================================== A> --- user/ae/inet6/sys/netinet6/in6.c Thu Jan 17 02:23:40 2013 (r245528) A> +++ user/ae/inet6/sys/netinet6/in6.c Thu Jan 17 02:30:32 2013 (r245529) A> @@ -2703,17 +2703,13 @@ in6_domifattach(struct ifnet *ifp) A> { A> struct in6_ifextra *ext; A> A> - ext = (struct in6_ifextra *)malloc(sizeof(*ext), M_IFADDR, M_WAITOK); A> - bzero(ext, sizeof(*ext)); A> - A> - ext->in6_ifstat = (struct in6_ifstat *)malloc(sizeof(struct in6_ifstat), A> - M_IFADDR, M_WAITOK); A> - bzero(ext->in6_ifstat, sizeof(*ext->in6_ifstat)); A> - A> + ext = (struct in6_ifextra *)malloc(sizeof(*ext), M_IFADDR, A> + M_WAITOK | M_ZERO); A> + ext->in6_ifstat = (struct in6_ifstat *)malloc( A> + sizeof(struct in6_ifstat), M_IFADDR, M_WAITOK | M_ZERO); A> ext->icmp6_ifstat = A> (struct icmp6_ifstat *)malloc(sizeof(struct icmp6_ifstat), A> - M_IFADDR, M_WAITOK); A> - bzero(ext->icmp6_ifstat, sizeof(*ext->icmp6_ifstat)); A> + M_IFADDR, M_WAITOK | M_ZERO); A> A> ext->nd_ifinfo = nd6_ifattach(ifp); A> ext->scope6_id = scope6_ifattach(ifp); A> @@ -2723,10 +2719,9 @@ in6_domifattach(struct ifnet *ifp) A> ext->lltable->llt_lookup = in6_lltable_lookup; A> ext->lltable->llt_dump = in6_lltable_dump; A> } A> - A> ext->mld_ifinfo = mld_domifattach(ifp); A> A> - return ext; A> + return (ext); A> } A> A> void Since your commit improves style(9), you could also remove casts before malloc(). -- Totus tuus, Glebius. From owner-svn-src-user@FreeBSD.ORG Thu Jan 17 22:30:56 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4340EFE8; Thu, 17 Jan 2013 22:30:56 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (unknown [IPv6:2001:610:1108:5012::107]) by mx1.freebsd.org (Postfix) with ESMTP id CF9DA941; Thu, 17 Jan 2013 22:30:55 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 9048B1203EF; Thu, 17 Jan 2013 23:30:39 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id 79EF12848C; Thu, 17 Jan 2013 23:30:39 +0100 (CET) Date: Thu, 17 Jan 2013 23:30:39 +0100 From: Jilles Tjoelker To: Sean Bruno Subject: Re: svn commit: r245486 - in user/sbruno/pxestuff/sys/boot/i386: . btx/btx btx/lib libi386 pxehttp Message-ID: <20130117223039.GA44915@stack.nl> References: <201301160149.r0G1n8Wl026588@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201301160149.r0G1n8Wl026588@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: src-committers@freebsd.org, svn-src-user@freebsd.org X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jan 2013 22:30:56 -0000 On Wed, Jan 16, 2013 at 01:49:08AM +0000, Sean Bruno wrote: > Author: sbruno > Date: Wed Jan 16 01:49:07 2013 > New Revision: 245486 > URL: http://svnweb.freebsd.org/changeset/base/245486 > Log: > First day of work on pxe_http restoral, merge in some janky assembly that > better get some serious reviews from people whom are way smarter than I. > Added: > user/sbruno/pxestuff/sys/boot/i386/pxehttp/ > [snip] > Modified: > user/sbruno/pxestuff/sys/boot/i386/Makefile > user/sbruno/pxestuff/sys/boot/i386/btx/btx/btx.S > user/sbruno/pxestuff/sys/boot/i386/btx/lib/btxsys.s > user/sbruno/pxestuff/sys/boot/i386/btx/lib/btxv86.h > user/sbruno/pxestuff/sys/boot/i386/libi386/Makefile > [snip] > Modified: user/sbruno/pxestuff/sys/boot/i386/btx/btx/btx.S > ============================================================================== > --- user/sbruno/pxestuff/sys/boot/i386/btx/btx/btx.S Wed Jan 16 01:30:46 2013 (r245485) > +++ user/sbruno/pxestuff/sys/boot/i386/btx/btx/btx.S Wed Jan 16 01:49:07 2013 (r245486) > @@ -52,7 +52,8 @@ > .set SEL_RDATA,0x20 # Real mode data > .set SEL_UCODE,0x28|3 # User code > .set SEL_UDATA,0x30|3 # User data > - .set SEL_TSS,0x38 # TSS > + .set SEL_TSS,0x38 # TSS > + .set SEL_CALLGATE,0x40 # super2user callgate This cannot work, see below. > /* > * Task state segment fields. > */ > @@ -62,8 +63,9 @@ > /* > * System calls. > */ > - .set SYS_EXIT,0x0 # Exit > - .set SYS_EXEC,0x1 # Exec > + .set SYS_EXIT,0x0 # Exit > + .set SYS_EXEC,0x1 # Exec > + .set SYS_ISR_INSTALL,0x2 # ISR_install > /* > * Fields in V86 interface structure. > */ > @@ -366,7 +368,6 @@ except.2: pushl 0x50(%esp,1) # Set ESP > popl %es # data > movl %esp,%ebx # Stack frame > movl $dmpfmt,%esi # Dump format string > - movl $MEM_BUF,%edi # Buffer > pushl %edi # Dump to > call dump # buffer > popl %esi # and Is this deletion deliberate? It seems to cause the crash message to be written to whatever address happens to be in %edi instead of to the buffer reserved for that purpose. > @@ -690,7 +691,9 @@ rret_tramp.3: popl %es # Restore > /* > * System Call. > */ > -intx30: cmpl $SYS_EXEC,%eax # Exec system call? > +intx30: cmpl $SYS_ISR_INSTALL, %eax # is isr_install? > + je intx30.2 # yes > + cmpl $SYS_EXEC,%eax # Exec system call? > jne intx30.1 # No > pushl %ss # Set up > popl %es # all > @@ -708,6 +711,74 @@ intx30: cmpl $SYS_EXEC,%eax # Exec sys > intx30.1: orb $0x1,%ss:btx_hdr+0x7 # Flag reboot > jmp exit # Exit > /* > + * Here we need to modify IDT in such way, that at interrupt handle > + * will be run isr_trump, which role is to run provided function > + * in user space. > + */ > +intx30.2: > + cli > + pushl %edi > + pushl %ebx > + pushw %ds > + pushw %dx It looks a bit too clever to use the 16-bit operand size here. The risk of accidentally modifying the top 16 bits of %edx and the two additional bytes of code are more important than the four bytes of stack space. > + > + pushl %ss # Set up > + popl %ds # registers > + > + > + movl $MEM_USR,%ebx # User base address > + addl 0x18(%esp,1),%ebx # getting user stack head > + addl $0x04, %ebx # first parameter > + > + movl (%ebx), %eax > + movw 0x2(%ebx), %dx > + xchgw %dx, %bx I do not understand these two instructions. They appear to set %dx to the high 16 bits of the function pointer in a roundabout way, but nothing is done with that subsequently. > + > +/* > + * updating call gate > + */ > + movl $callgate, %edi You can load the address in a register but it does not appear to save any code bytes here. > + movw %ax, (%edi) # +0: store offset 00..15 > + shr $0x10 ,%eax # getting high word > + movw %ax, 0x06(%edi) # +6: handler offset 16..31 > +/* > + * installing handler > + */ > +/* > + * NOTE: it seems nothing else must be done > + */ > + popw %dx > + popw %ds > + popl %ebx > + popl %edi > + sti > + iret # return from syscall > + > +user_isr_call: > +/* > + * NOTE: isr must use lret to return and restore SS, ESP, CS, EIP. This is in fact iret, not lret. > +*/ > + pushl %ds # saving ds > + pushl %edi > + movl $SEL_SDATA, %eax # You're overwriting %eax without saving and restoring it. > + movl %eax, %ds > + > + movl $callgate, %edi > + movw (%edi), %ax You can move from callgate directly; there is no need to load the address into a register first. > + popl %edi > + > + cmpw $0x0000, %ax testw %ax, %ax (or cleverly testl %ax, %ax to save another byte) > + je isr_ret > + > + lcall $SEL_CALLGATE,$0x00000000 # far call via callgate selector > + # offset is ignored You cannot call to a less privileged code segment, not even via a call gate. This is because the return would have to allow the less privileged code segment to "return" to any code segment and offset. It may work to execute the user code in ring 0. This requires a new code segment descriptor with MEM_USR base. The call gate is not necessary because a regular far call can be used. Make sure to adjust the exception handler so it checks the privilege level of the crashing code properly instead of assuming that only SEL_SCODE is ring 0. Alternatively, jump to the user code using iret and have it call another system call to resume. > +isr_ret: > + > + > + popl %ds > + > + iret # return from interrupt handler > +/* > * Dump structure [EBX] to [EDI], using format string [ESI]. > */ > dump.0: stosb # Save char > @@ -1000,6 +1071,7 @@ gdt: .word 0x0,0x0,0x0,0x0 # Null entr > .word 0xffff,MEM_USR,0xfa00,0xcf# SEL_UCODE > .word 0xffff,MEM_USR,0xf200,0xcf# SEL_UDATA > tss_desc: .word _TSSLM,MEM_TSS,0x8900,0x0 # SEL_TSS > +callgate: .word 0x0, SEL_UCODE,0xec00,0x0 # SEL_CALLGATE > gdt.1: > /* > * Pseudo-descriptors. > > Modified: user/sbruno/pxestuff/sys/boot/i386/btx/lib/btxsys.s > ============================================================================== > --- user/sbruno/pxestuff/sys/boot/i386/btx/lib/btxsys.s Wed Jan 16 01:30:46 2013 (r245485) > +++ user/sbruno/pxestuff/sys/boot/i386/btx/lib/btxsys.s Wed Jan 16 01:49:07 2013 (r245486) > @@ -24,6 +24,7 @@ > # > .global __exit > .global __exec > + .global __isr_install > # > # Constants. > # > @@ -38,3 +39,8 @@ __exit: xorl %eax,%eax # BTX system > # > __exec: movl $0x1,%eax # BTX system > int $INT_SYS # call 0x1 > +# > +# System call: isr_install > +# > +__isr_install: movl $0x2,%eax # BTX system > + int $INT_SYS # call 0x2 A ret instruction is probably required here because the new system call returns (different from the existing two). -- Jilles Tjoelker From owner-svn-src-user@FreeBSD.ORG Fri Jan 18 02:50:10 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id CDF55C3C; Fri, 18 Jan 2013 02:50:10 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A81BB770; Fri, 18 Jan 2013 02:50:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0I2oAPA011591; Fri, 18 Jan 2013 02:50:10 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0I2oA6s011590; Fri, 18 Jan 2013 02:50:10 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201301180250.r0I2oA6s011590@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Fri, 18 Jan 2013 02:50:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245585 - user/ae/inet6/sys/netinet6 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jan 2013 02:50:10 -0000 Author: ae Date: Fri Jan 18 02:50:10 2013 New Revision: 245585 URL: http://svnweb.freebsd.org/changeset/base/245585 Log: Remove usage of in6_recoverscope and in6_clearscope functions, they will be not needed, I hope. Modified: user/ae/inet6/sys/netinet6/in6.c Modified: user/ae/inet6/sys/netinet6/in6.c ============================================================================== --- user/ae/inet6/sys/netinet6/in6.c Fri Jan 18 02:36:06 2013 (r245584) +++ user/ae/inet6/sys/netinet6/in6.c Fri Jan 18 02:50:10 2013 (r245585) @@ -538,8 +538,6 @@ in6_control(struct socket *so, u_long cm switch (cmd) { case SIOCGIFADDR_IN6: ifr->ifr_addr = ia->ia_addr; - if ((error = sa6_recoverscope(&ifr->ifr_addr)) != 0) - goto out; break; case SIOCGIFDSTADDR_IN6: @@ -552,8 +550,6 @@ in6_control(struct socket *so, u_long cm * an error? */ ifr->ifr_dstaddr = ia->ia_dstaddr; - if ((error = sa6_recoverscope(&ifr->ifr_dstaddr)) != 0) - goto out; break; case SIOCGIFNETMASK_IN6: @@ -1771,7 +1767,6 @@ in6_lifaddr_ioctl(struct socket *so, u_l * link-local address. */ bcopy(IFA_IN6(ifa), &candidate, sizeof(candidate)); - in6_clearscope(&candidate); candidate.s6_addr32[0] &= mask.s6_addr32[0]; candidate.s6_addr32[1] &= mask.s6_addr32[1]; candidate.s6_addr32[2] &= mask.s6_addr32[2]; @@ -1787,26 +1782,11 @@ in6_lifaddr_ioctl(struct socket *so, u_l ia = ifa2ia6(ifa); if (cmd == SIOCGLIFADDR) { - int error; - /* fill in the if_laddrreq structure */ bcopy(&ia->ia_addr, &iflr->addr, ia->ia_addr.sin6_len); - error = sa6_recoverscope( - (struct sockaddr_in6 *)&iflr->addr); - if (error != 0) { - ifa_free(ifa); - return (error); - } - if ((ifp->if_flags & IFF_POINTOPOINT) != 0) { bcopy(&ia->ia_dstaddr, &iflr->dstaddr, ia->ia_dstaddr.sin6_len); - error = sa6_recoverscope( - (struct sockaddr_in6 *)&iflr->dstaddr); - if (error != 0) { - ifa_free(ifa); - return (error); - } } else bzero(&iflr->dstaddr, sizeof(iflr->dstaddr)); @@ -1815,8 +1795,7 @@ in6_lifaddr_ioctl(struct socket *so, u_l iflr->flags = ia->ia6_flags; /* XXX */ ifa_free(ifa); - - return 0; + return (0); } else { struct in6_aliasreq ifra; @@ -2670,8 +2649,6 @@ in6_lltable_dump(struct lltable *llt, st ndpc.sin6.sin6_family = AF_INET6; ndpc.sin6.sin6_len = sizeof(ndpc.sin6); bcopy(L3_ADDR(lle), &ndpc.sin6, L3_ADDR_LEN(lle)); - if (V_deembed_scopeid) - sa6_recoverscope(&ndpc.sin6); /* publish */ if (lle->la_flags & LLE_PUB) From owner-svn-src-user@FreeBSD.ORG Fri Jan 18 04:51:38 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E63BB766; Fri, 18 Jan 2013 04:51:38 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id D4BABCC2; Fri, 18 Jan 2013 04:51:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0I4pcsw051275; Fri, 18 Jan 2013 04:51:38 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0I4pcOm051274; Fri, 18 Jan 2013 04:51:38 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201301180451.r0I4pcOm051274@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Fri, 18 Jan 2013 04:51:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245588 - user/ae/inet6/sys/netinet6 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jan 2013 04:51:39 -0000 Author: ae Date: Fri Jan 18 04:51:38 2013 New Revision: 245588 URL: http://svnweb.freebsd.org/changeset/base/245588 Log: Since we keep addresses without embedded zone id, sa6_embedscope and in6_setscope aren't needed here. Modified: user/ae/inet6/sys/netinet6/in6.c Modified: user/ae/inet6/sys/netinet6/in6.c ============================================================================== --- user/ae/inet6/sys/netinet6/in6.c Fri Jan 18 04:23:54 2013 (r245587) +++ user/ae/inet6/sys/netinet6/in6.c Fri Jan 18 04:51:38 2013 (r245588) @@ -435,12 +435,6 @@ in6_control(struct socket *so, u_long cm break; } if (sa6 && sa6->sin6_family == AF_INET6) { - if (sa6->sin6_scope_id != 0) - error = sa6_embedscope(sa6, 0); - else - error = in6_setscope(&sa6->sin6_addr, ifp, NULL); - if (error != 0) - return (error); if (td != NULL && (error = prison_check_ip6(td->td_ucred, &sa6->sin6_addr)) != 0) return (error); From owner-svn-src-user@FreeBSD.ORG Fri Jan 18 10:19:51 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 0664F74E; Fri, 18 Jan 2013 10:19:51 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id DE9E2CC7; Fri, 18 Jan 2013 10:19:50 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0IAJonP048598; Fri, 18 Jan 2013 10:19:50 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0IAJoU6048597; Fri, 18 Jan 2013 10:19:50 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201301181019.r0IAJoU6048597@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Fri, 18 Jan 2013 10:19:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245597 - user/ae/inet6/sys/netinet6 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jan 2013 10:19:51 -0000 Author: ae Date: Fri Jan 18 10:19:50 2013 New Revision: 245597 URL: http://svnweb.freebsd.org/changeset/base/245597 Log: Clean up from use of embedded zone ids. Modified: user/ae/inet6/sys/netinet6/in6_mcast.c Modified: user/ae/inet6/sys/netinet6/in6_mcast.c ============================================================================== --- user/ae/inet6/sys/netinet6/in6_mcast.c Fri Jan 18 10:11:54 2013 (r245596) +++ user/ae/inet6/sys/netinet6/in6_mcast.c Fri Jan 18 10:19:50 2013 (r245597) @@ -1161,21 +1161,6 @@ in6_mc_join_locked(struct ifnet *ifp, co #ifdef KTR char ip6tbuf[INET6_ADDRSTRLEN]; #endif - -#ifdef INVARIANTS - /* - * Sanity: Check scope zone ID was set for ifp, if and - * only if group is scoped to an interface. - */ - KASSERT(IN6_IS_ADDR_MULTICAST(mcaddr), - ("%s: not a multicast address", __func__)); - if (IN6_IS_ADDR_MC_LINKLOCAL(mcaddr) || - IN6_IS_ADDR_MC_INTFACELOCAL(mcaddr)) { - KASSERT(mcaddr->s6_addr16[1] != 0, - ("%s: scope zone ID not set", __func__)); - } -#endif - IN6_MULTI_LOCK_ASSERT(); CTR4(KTR_MLD, "%s: join %s on %p(%s))", __func__, @@ -1376,8 +1361,6 @@ in6p_block_unblock_source(struct inpcb * if (!IN6_IS_ADDR_MULTICAST(&gsa->sin6.sin6_addr)) return (EINVAL); - (void)in6_setscope(&gsa->sin6.sin6_addr, ifp, NULL); - /* * Check if we are actually a member of this group. */ @@ -1595,7 +1578,6 @@ in6p_get_source_filters(struct inpcb *in ifp = ifnet_byindex(msfr.msfr_ifindex); if (ifp == NULL) return (EADDRNOTAVAIL); - (void)in6_setscope(&gsa->sin6.sin6_addr, ifp, NULL); INP_WLOCK(inp); @@ -1882,7 +1864,6 @@ in6p_join_group(struct inpcb *inp, struc * list entry against passed-in ifp, if and only * if source list filter entry is iface or node local. */ - in6_clearscope(&ssa->sin6.sin6_addr); ssa->sin6.sin6_port = 0; ssa->sin6.sin6_scope_id = 0; } @@ -1909,12 +1890,9 @@ in6p_join_group(struct inpcb *inp, struc gsa->sin6.sin6_scope_id = 0; /* - * Always set the scope zone ID on memberships created from userland. + * XXX Always set the scope zone ID on memberships created from userland. * Use the passed-in ifp to do this. - * XXX The in6_setscope() return value is meaningless. - * XXX SCOPE6_LOCK() is taken by in6_setscope(). */ - (void)in6_setscope(&gsa->sin6.sin6_addr, ifp, NULL); imo = in6p_findmoptions(inp); idx = im6o_match_group(imo, ifp, &gsa->sa); @@ -2166,7 +2144,6 @@ in6p_leave_group(struct inpcb *inp, stru * list entry against passed-in ifp, if and only * if source list filter entry is iface or node local. */ - in6_clearscope(&ssa->sin6.sin6_addr); } gsa->sin6.sin6_port = 0; gsa->sin6.sin6_scope_id = 0; @@ -2184,23 +2161,18 @@ in6p_leave_group(struct inpcb *inp, stru return (EINVAL); /* - * Validate interface index if provided. If no interface index + * XXX Validate interface index if provided. If no interface index * was provided separately, attempt to look the membership up * from the default scope as a last resort to disambiguate * the membership we are being asked to leave. - * XXX SCOPE6 lock potentially taken here. */ if (ifindex != 0) { - if (ifindex < 0 || V_if_index < ifindex) + if (V_if_index < ifindex) return (EADDRNOTAVAIL); ifp = ifnet_byindex(ifindex); if (ifp == NULL) return (EADDRNOTAVAIL); - (void)in6_setscope(&gsa->sin6.sin6_addr, ifp, NULL); } else { - error = sa6_embedscope(&gsa->sin6, V_ip6_use_defzone); - if (error) - return (EADDRNOTAVAIL); /* * Some badly behaved applications don't pass an ifindex * or a scope ID, which is an API violation. In this case, @@ -2211,15 +2183,10 @@ in6p_leave_group(struct inpcb *inp, stru * directly until such time as this implementation is * refactored, assuming the scope IDs are the way to go. */ - ifindex = ntohs(gsa->sin6.sin6_addr.s6_addr16[1]); - if (ifindex == 0) { - CTR2(KTR_MLD, "%s: warning: no ifindex, looking up " - "ifp for group %s.", __func__, - ip6_sprintf(ip6tbuf, &gsa->sin6.sin6_addr)); - ifp = in6p_lookup_mcast_ifp(inp, &gsa->sin6); - } else { - ifp = ifnet_byindex(ifindex); - } + CTR2(KTR_MLD, "%s: warning: no ifindex, looking up " + "ifp for group %s.", __func__, + ip6_sprintf(ip6tbuf, &gsa->sin6.sin6_addr)); + ifp = in6p_lookup_mcast_ifp(inp, &gsa->sin6); if (ifp == NULL) return (EADDRNOTAVAIL); } @@ -2349,7 +2316,7 @@ in6p_set_multicast_if(struct inpcb *inp, error = sooptcopyin(sopt, &ifindex, sizeof(u_int), sizeof(u_int)); if (error) return (error); - if (ifindex < 0 || V_if_index < ifindex) + if (V_if_index < ifindex) return (EINVAL); ifp = ifnet_byindex(ifindex); @@ -2407,8 +2374,6 @@ in6p_set_source_filters(struct inpcb *in ifp = ifnet_byindex(msfr.msfr_ifindex); if (ifp == NULL) return (EADDRNOTAVAIL); - (void)in6_setscope(&gsa->sin6.sin6_addr, ifp, NULL); - /* * Take the INP write lock. * Check if this socket is a member of this group. @@ -2494,7 +2459,6 @@ in6p_set_source_filters(struct inpcb *in * list entry against passed-in ifp, if and only * if source list filter entry is iface or node local. */ - in6_clearscope(&psin->sin6_addr); error = im6f_get_source(imf, psin, &lims); if (error) break; @@ -2707,7 +2671,6 @@ sysctl_ip6_mcast_filters(SYSCTL_HANDLER_ /* * Internal MLD lookups require that scope/zone ID is set. */ - (void)in6_setscope(&mcaddr, ifp, NULL); retval = sysctl_wire_old_buffer(req, sizeof(uint32_t) + (in6_mcast_maxgrpsrc * sizeof(struct in6_addr))); From owner-svn-src-user@FreeBSD.ORG Fri Jan 18 12:58:11 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 51FB171A; Fri, 18 Jan 2013 12:58:11 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 34B1B71B; Fri, 18 Jan 2013 12:58:11 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0ICwB61095932; Fri, 18 Jan 2013 12:58:11 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0ICwAsu095930; Fri, 18 Jan 2013 12:58:10 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201301181258.r0ICwAsu095930@svn.freebsd.org> From: Sean Bruno Date: Fri, 18 Jan 2013 12:58:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245602 - user/sbruno/pxestuff/sys/boot/i386/libi386 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jan 2013 12:58:11 -0000 Author: sbruno Date: Fri Jan 18 12:58:10 2013 New Revision: 245602 URL: http://svnweb.freebsd.org/changeset/base/245602 Log: Adjust Makefile for my arbitrary rename of pxe_http -> pxehttp. Add more more merges from SOC pxe_http project into libi386 - this adds the theoretical ability to use pxehttp for the packet driver parts in libstand if the user does not want all of the wonderous http goodness. Modified: user/sbruno/pxestuff/sys/boot/i386/libi386/Makefile user/sbruno/pxestuff/sys/boot/i386/libi386/pxe.c Modified: user/sbruno/pxestuff/sys/boot/i386/libi386/Makefile ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/libi386/Makefile Fri Jan 18 11:45:14 2013 (r245601) +++ user/sbruno/pxestuff/sys/boot/i386/libi386/Makefile Fri Jan 18 12:58:10 2013 (r245602) @@ -42,13 +42,21 @@ CFLAGS+= -DSMBIOS_LITTLE_ENDIAN_UUID # Include simple terminal emulation (cons25-compatible) CFLAGS+= -DTERM_EMU +# Enable PXE debugging +#CDLAGS+= -DPXE_DEBUG + +# Allow pxe_http perform udpread/udpwrite +.if defined(PXEHTTP_UDP_FOR_LIBSTAND) +CFLAGS+= -DPXEHTTP_UDP_FOR_LIBSTAND +.endif + # XXX: make alloca() useable CFLAGS+= -Dalloca=__builtin_alloca CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../common \ -I${.CURDIR}/../btx/lib \ -I${.CURDIR}/../../../contrib/dev/acpica/include \ - -I${.CURDIR}/../../.. -I. -I${.CURDIR}/../pxe_http/ + -I${.CURDIR}/../../.. -I. -I${.CURDIR}/../pxehttp/ # the location of libstand CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/ Modified: user/sbruno/pxestuff/sys/boot/i386/libi386/pxe.c ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/libi386/pxe.c Fri Jan 18 11:45:14 2013 (r245601) +++ user/sbruno/pxestuff/sys/boot/i386/libi386/pxe.c Fri Jan 18 12:58:10 2013 (r245602) @@ -39,23 +39,32 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef LOADER_NFS_SUPPORT #include +#endif #include #include #include #include "btxv86.h" #include "pxe.h" +#include "pxe_core.h" +#include "pxe_dhcp.h" +#include "pxe_isr.h" +#include "pxe_ip.h" +#include "pxe_udp.h" +#define PXE_TFTP_BUFFER_SIZE 512 +#ifdef PXEHTTP_UDP_FOR_LIBSTAND /* * Allocate the PXE buffers statically instead of sticking grimy fingers into * BTX's private data area. The scratch buffer is used to send information to * the PXE BIOS, and the data buffer is used to receive data from the PXE BIOS. */ #define PXE_BUFFER_SIZE 0x2000 -#define PXE_TFTP_BUFFER_SIZE 512 static char scratch_buffer[PXE_BUFFER_SIZE]; static char data_buffer[PXE_BUFFER_SIZE]; +#endif static pxenv_t *pxenv_p = NULL; /* PXENV+ */ static pxe_t *pxe_p = NULL; /* !PXE */ @@ -159,6 +168,12 @@ pxe_enable(void *pxeinfo) static int pxe_init(void) { +#ifdef PXEHTTP_UDP_FOR_LIBSTAND + if (__pxe_nic_irq != 0) + return (2); + + return pxe_core_init(pxenv_p, pxe_p); +#else t_PXENV_GET_CACHED_INFO *gci_p; int counter; uint8_t checksum; @@ -243,6 +258,7 @@ pxe_init(void) bcopy(PTOV((gci_p->Buffer.segment << 4) + gci_p->Buffer.offset), &bootplayer, gci_p->BufferSize); return (1); +#endif } @@ -279,6 +295,13 @@ pxe_open(struct open_file *f, ...) printf("pxe_open: netif_open() succeeded\n"); } if (rootip.s_addr == 0) { +#ifdef PXEHTTP_UDP_FOR_LIBSTAND + gateip.s_addr = pxe_get_ip(PXE_IP_GATEWAY)->ip; + rootip.s_addr = pxe_get_ip(PXE_IP_ROOT)->ip; + netmask = pxe_get_ip(PXE_IP_NETMASK)->ip; + myip.s_addr = pxe_get_ip(PXE_IP_MY)->ip; + nameip.s_addr = pxe_get_ip(PXE_IP_NAMESERVER)->ip; +#else /* * Do a bootp/dhcp request to find out where our * NFS/TFTP server is. Even if we dont get back @@ -286,6 +309,7 @@ pxe_open(struct open_file *f, ...) * which brought us to life and a default rootpath. */ bootp(pxe_sock, BOOTP_PXE); +#endif if (rootip.s_addr == 0) rootip.s_addr = bootplayer.sip; if (!rootpath[0]) @@ -633,6 +657,27 @@ pxe_netif_put(struct iodesc *desc, void ssize_t sendudp(struct iodesc *h, void *pkt, size_t len) { +#ifdef PXEHTTP_UDP_FOR_LIBSTAND +#ifdef PXE_DEBUG_HELL + printf("sendudp(): sending %u bytes from me:%u -> %s:%u\n", + len, ntohs(h->myport), + inet_ntoa(h->destip), ntohs(h->destport)); +#endif /* PXE_DEBUG_HELL */ + void *ipdata = pkt - sizeof(PXE_UDP_PACKET); + + PXE_IPADDR dst; + dst.ip = h->destip.s_addr; + + if (!pxe_udp_send(ipdata, &dst, ntohs(h->destport), + ntohs(h->myport), len + sizeof(PXE_UDP_PACKET))) + { + printf("sendudp(): failed\n"); + return (-1); + } + + return (len); + +#else /* PXEHTTP_UDP_FOR_LIBSTAND */ t_PXENV_UDP_WRITE *udpwrite_p = (t_PXENV_UDP_WRITE *)scratch_buffer; bzero(udpwrite_p, sizeof(*udpwrite_p)); @@ -661,11 +706,34 @@ sendudp(struct iodesc *h, void *pkt, siz return -1; } return len; +#endif /* PXEHTTP_UDP_FOR_LIBSTATND */ } ssize_t readudp(struct iodesc *h, void *pkt, size_t len, time_t timeout) { +#ifdef PXEHTTP_UDP_FOR_LIBSTAND + PXE_UDP_DGRAM dgram; + struct udphdr *uh = (struct udphdr *) pkt - 1; + + /* process any queued incoming packets */ + pxe_core_recv_packets(); + + /* reading from default socket */ + int recv = pxe_udp_read(NULL, pkt, len, &dgram); + + if (recv == -1) { + printf("readudp(): failed\n"); + return (-1); + } +#ifdef PXE_DEBUG_HELL + printf("readudp(): received %d(%u/%u) bytes from %u port\n", + recv, len, dgram.size, dgram.src_port); +#endif + uh->uh_sport = htons(dgram.src_port); + + return (recv); +#else /* PXEHTTP_UDP_FOR_LIBSTAND */ t_PXENV_UDP_READ *udpread_p = (t_PXENV_UDP_READ *)scratch_buffer; struct udphdr *uh = NULL; @@ -693,4 +761,5 @@ readudp(struct iodesc *h, void *pkt, siz bcopy(data_buffer, pkt, udpread_p->buffer_size); uh->uh_sport = udpread_p->s_port; return udpread_p->buffer_size; +#endif /* PXEHTTP_UDP_FOR_LIBSTAND */ } From owner-svn-src-user@FreeBSD.ORG Fri Jan 18 13:08:17 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id BDC1FA92; Fri, 18 Jan 2013 13:08:17 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A0B22781; Fri, 18 Jan 2013 13:08:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0ID8HqW099148; Fri, 18 Jan 2013 13:08:17 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0ID8H46099147; Fri, 18 Jan 2013 13:08:17 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201301181308.r0ID8H46099147@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Fri, 18 Jan 2013 13:08:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245603 - user/ae/inet6/sys/netinet6 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jan 2013 13:08:17 -0000 Author: ae Date: Fri Jan 18 13:08:17 2013 New Revision: 245603 URL: http://svnweb.freebsd.org/changeset/base/245603 Log: Another step of embedding zone ids cleanup. Modified: user/ae/inet6/sys/netinet6/in6.c Modified: user/ae/inet6/sys/netinet6/in6.c ============================================================================== --- user/ae/inet6/sys/netinet6/in6.c Fri Jan 18 12:58:10 2013 (r245602) +++ user/ae/inet6/sys/netinet6/in6.c Fri Jan 18 13:08:17 2013 (r245603) @@ -842,11 +842,6 @@ in6_update_ifa_join_mc(struct ifnet *ifp llsol.s6_addr32[2] = htonl(1); llsol.s6_addr32[3] = ifra->ifra_addr.sin6_addr.s6_addr32[3]; llsol.s6_addr8[12] = 0xff; - if ((error = in6_setscope(&llsol, ifp, NULL)) != 0) { - /* XXX: should not happen */ - log(LOG_ERR, "%s: in6_setscope failed\n", __func__); - goto cleanup; - } delay = 0; if ((flags & IN6_IFAUPDATE_DADDELAY)) { /* @@ -859,7 +854,7 @@ in6_update_ifa_join_mc(struct ifnet *ifp } imm = in6_joingroup(ifp, &llsol, &error, delay); if (imm == NULL) { - nd6log((LOG_WARNING, "%s: addmulti failed for %s on %s " + nd6log((LOG_WARNING, "%s: in6_joingroup failed for %s on %s " "(errno=%d)\n", __func__, ip6_sprintf(ip6buf, &llsol), if_name(ifp), error)); goto cleanup; @@ -880,9 +875,6 @@ in6_update_ifa_join_mc(struct ifnet *ifp mltaddr.sin6_len = sizeof(struct sockaddr_in6); mltaddr.sin6_family = AF_INET6; mltaddr.sin6_addr = in6addr_linklocal_allnodes; - if ((error = in6_setscope(&mltaddr.sin6_addr, ifp, NULL)) != 0) - goto cleanup; /* XXX: should not fail */ - /* * XXX: do we really need this automatic routes? We should probably * reconsider this stuff. Most applications actually do not need the @@ -890,7 +882,6 @@ in6_update_ifa_join_mc(struct ifnet *ifp */ rt = in6_rtalloc1((struct sockaddr *)&mltaddr, 0, 0UL, RT_DEFAULT_FIB); if (rt != NULL) { - /* XXX: only works in !SCOPEDROUTING case. */ if (memcmp(&mltaddr.sin6_addr, &((struct sockaddr_in6 *)rt_key(rt))->sin6_addr, MLTMASK_LEN)) { @@ -910,7 +901,7 @@ in6_update_ifa_join_mc(struct ifnet *ifp imm = in6_joingroup(ifp, &mltaddr.sin6_addr, &error, 0); if (imm == NULL) { - nd6log((LOG_WARNING, "%s: addmulti failed for %s on %s " + nd6log((LOG_WARNING, "%s: in6_joingroup failed for %s on %s " "(errno=%d)\n", __func__, ip6_sprintf(ip6buf, &mltaddr.sin6_addr), if_name(ifp), error)); goto cleanup; @@ -932,8 +923,8 @@ in6_update_ifa_join_mc(struct ifnet *ifp /* XXX jinmei */ imm = in6_joingroup(ifp, &mltaddr.sin6_addr, &error, delay); if (imm == NULL) - nd6log((LOG_WARNING, "%s: addmulti failed for %s on %s " - "(errno=%d)\n", __func__, ip6_sprintf(ip6buf, + nd6log((LOG_WARNING, "%s: in6_joingroup failed for %s " + "on %s (errno=%d)\n", __func__, ip6_sprintf(ip6buf, &mltaddr.sin6_addr), if_name(ifp), error)); /* XXX not very fatal, go on... */ else @@ -945,8 +936,6 @@ in6_update_ifa_join_mc(struct ifnet *ifp * (ff01::1%ifN, and ff01::%ifN/32) */ mltaddr.sin6_addr = in6addr_nodelocal_allnodes; - if ((error = in6_setscope(&mltaddr.sin6_addr, ifp, NULL)) != 0) - goto cleanup; /* XXX: should not fail */ /* XXX: again, do we really need the route? */ rt = in6_rtalloc1((struct sockaddr *)&mltaddr, 0, 0UL, RT_DEFAULT_FIB); if (rt != NULL) { @@ -969,7 +958,7 @@ in6_update_ifa_join_mc(struct ifnet *ifp imm = in6_joingroup(ifp, &mltaddr.sin6_addr, &error, 0); if (imm == NULL) { - nd6log((LOG_WARNING, "%s: addmulti failed for %s on %s " + nd6log((LOG_WARNING, "%s: in6_joingroup failed for %s on %s " "(errno=%d)\n", __func__, ip6_sprintf(ip6buf, &mltaddr.sin6_addr), if_name(ifp), error)); goto cleanup; @@ -978,6 +967,7 @@ in6_update_ifa_join_mc(struct ifnet *ifp #undef MLTMASK_LEN cleanup: + /* XXX */ return (error); } @@ -1044,22 +1034,7 @@ in6_update_ifa(struct ifnet *ifp, struct dst6 = ifra->ifra_dstaddr; if ((ifp->if_flags & (IFF_POINTOPOINT|IFF_LOOPBACK)) != 0 && (dst6.sin6_family == AF_INET6)) { - struct in6_addr in6_tmp; - u_int32_t zoneid; - - in6_tmp = dst6.sin6_addr; - if (in6_setscope(&in6_tmp, ifp, &zoneid)) - return (EINVAL); /* XXX: should be impossible */ - - if (dst6.sin6_scope_id != 0) { - if (dst6.sin6_scope_id != zoneid) - return (EINVAL); - } else /* user omit to specify the ID. */ - dst6.sin6_scope_id = zoneid; - - /* convert into the internal form */ - if (sa6_embedscope(&dst6, 0)) - return (EINVAL); /* XXX: should be impossible */ + /* XXX: check a scope zone id */ } /* * The destination address can be specified only for a p2p or a @@ -1170,6 +1145,7 @@ in6_update_ifa(struct ifnet *ifp, struct * If a new destination address is specified, scrub the old one and * install the new destination. Note that the interface must be * p2p or loopback (see the check above.) + * XXX: check scope zone id */ if (dst6.sin6_family == AF_INET6 && !IN6_ARE_ADDR_EQUAL(&dst6.sin6_addr, &ia->ia_dstaddr.sin6_addr)) { @@ -1345,9 +1321,6 @@ in6_purgeaddr_mc(struct ifnet *ifp, stru mltaddr.sin6_family = AF_INET6; mltaddr.sin6_addr = in6addr_linklocal_allnodes; - if ((error = in6_setscope(&mltaddr.sin6_addr, ifp, NULL)) != 0) - return (error); - /* * As for the mltaddr above, proactively prepare the sin6 to avoid * rtentry un- and re-locking. @@ -1358,9 +1331,6 @@ in6_purgeaddr_mc(struct ifnet *ifp, stru sin6.sin6_family = AF_INET6; memcpy(&sin6.sin6_addr, &satosin6(ifa0->ifa_addr)->sin6_addr, sizeof(sin6.sin6_addr)); - error = in6_setscope(&sin6.sin6_addr, ifa0->ifa_ifp, NULL); - if (error != 0) - return (error); } rt = in6_rtalloc1((struct sockaddr *)&mltaddr, 0, 0UL, RT_DEFAULT_FIB); @@ -1402,9 +1372,6 @@ in6_purgeaddr_mc(struct ifnet *ifp, stru * Remove the node-local all-nodes address. */ mltaddr.sin6_addr = in6addr_nodelocal_allnodes; - if ((error = in6_setscope(&mltaddr.sin6_addr, ifp, NULL)) != 0) - return (error); - rt = in6_rtalloc1((struct sockaddr *)&mltaddr, 0, 0UL, RT_DEFAULT_FIB); if (rt != NULL && rt->rt_gateway != NULL && (memcmp(&satosin6(rt->rt_gateway)->sin6_addr, From owner-svn-src-user@FreeBSD.ORG Fri Jan 18 14:36:24 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 90B52318; Fri, 18 Jan 2013 14:36:24 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 7DB9ABDB; Fri, 18 Jan 2013 14:36:24 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0IEaOmf025789; Fri, 18 Jan 2013 14:36:24 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0IEaORX025787; Fri, 18 Jan 2013 14:36:24 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201301181436.r0IEaORX025787@svn.freebsd.org> From: Sean Bruno Date: Fri, 18 Jan 2013 14:36:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245605 - in user/sbruno/pxestuff/sys/boot/i386: btx/btx libi386 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jan 2013 14:36:24 -0000 Author: sbruno Date: Fri Jan 18 14:36:23 2013 New Revision: 245605 URL: http://svnweb.freebsd.org/changeset/base/245605 Log: btx.S - Probably not a good idea to write the crash message randomly. (jiles) pxe.c - Move some white space around to show that the new code is being run at the same point as old code in the #ifdef Modified: user/sbruno/pxestuff/sys/boot/i386/btx/btx/btx.S user/sbruno/pxestuff/sys/boot/i386/libi386/pxe.c Modified: user/sbruno/pxestuff/sys/boot/i386/btx/btx/btx.S ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/btx/btx/btx.S Fri Jan 18 13:16:02 2013 (r245604) +++ user/sbruno/pxestuff/sys/boot/i386/btx/btx/btx.S Fri Jan 18 14:36:23 2013 (r245605) @@ -368,6 +368,7 @@ except.2: pushl 0x50(%esp,1) # Set ESP popl %es # data movl %esp,%ebx # Stack frame movl $dmpfmt,%esi # Dump format string + movl $MEM_BUF,%edi # Buffer pushl %edi # Dump to call dump # buffer popl %esi # and Modified: user/sbruno/pxestuff/sys/boot/i386/libi386/pxe.c ============================================================================== --- user/sbruno/pxestuff/sys/boot/i386/libi386/pxe.c Fri Jan 18 13:16:02 2013 (r245604) +++ user/sbruno/pxestuff/sys/boot/i386/libi386/pxe.c Fri Jan 18 14:36:23 2013 (r245605) @@ -296,11 +296,11 @@ pxe_open(struct open_file *f, ...) } if (rootip.s_addr == 0) { #ifdef PXEHTTP_UDP_FOR_LIBSTAND - gateip.s_addr = pxe_get_ip(PXE_IP_GATEWAY)->ip; - rootip.s_addr = pxe_get_ip(PXE_IP_ROOT)->ip; - netmask = pxe_get_ip(PXE_IP_NETMASK)->ip; - myip.s_addr = pxe_get_ip(PXE_IP_MY)->ip; - nameip.s_addr = pxe_get_ip(PXE_IP_NAMESERVER)->ip; + gateip.s_addr = pxe_get_ip(PXE_IP_GATEWAY)->ip; + rootip.s_addr = pxe_get_ip(PXE_IP_ROOT)->ip; + netmask = pxe_get_ip(PXE_IP_NETMASK)->ip; + myip.s_addr = pxe_get_ip(PXE_IP_MY)->ip; + nameip.s_addr = pxe_get_ip(PXE_IP_NAMESERVER)->ip; #else /* * Do a bootp/dhcp request to find out where our From owner-svn-src-user@FreeBSD.ORG Fri Jan 18 16:32:34 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 2C08B732; Fri, 18 Jan 2013 16:32:34 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 1CBB0690; Fri, 18 Jan 2013 16:32:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0IGWXq9061766; Fri, 18 Jan 2013 16:32:34 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0IGWXuK061764; Fri, 18 Jan 2013 16:32:33 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201301181632.r0IGWXuK061764@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Fri, 18 Jan 2013 16:32:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245607 - user/ae/inet6/sys/netinet6 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jan 2013 16:32:34 -0000 Author: ae Date: Fri Jan 18 16:32:33 2013 New Revision: 245607 URL: http://svnweb.freebsd.org/changeset/base/245607 Log: Remove in6_setscope calls. Modified: user/ae/inet6/sys/netinet6/in6_ifattach.c Modified: user/ae/inet6/sys/netinet6/in6_ifattach.c ============================================================================== --- user/ae/inet6/sys/netinet6/in6_ifattach.c Fri Jan 18 15:57:09 2013 (r245606) +++ user/ae/inet6/sys/netinet6/in6_ifattach.c Fri Jan 18 16:32:33 2013 (r245607) @@ -675,10 +675,7 @@ in6_nigroup(struct ifnet *ifp, const cha in6->s6_addr16[0] = IPV6_ADDR_INT16_MLL; in6->s6_addr8[11] = 2; bcopy(digest, &in6->s6_addr32[3], sizeof(in6->s6_addr32[3])); - if (in6_setscope(in6, ifp, NULL)) - return (-1); /* XXX: should not fail */ - - return 0; + return (0); } /* @@ -856,9 +853,6 @@ in6_ifdetach(struct ifnet *ifp) sin6.sin6_len = sizeof(struct sockaddr_in6); sin6.sin6_family = AF_INET6; sin6.sin6_addr = in6addr_linklocal_allnodes; - if (in6_setscope(&sin6.sin6_addr, ifp, NULL)) - /* XXX: should not fail */ - return; /* XXX grab lock first to avoid LOR */ rnh = rt_tables_get_rnh(RT_DEFAULT_FIB, AF_INET6); if (rnh != NULL) { From owner-svn-src-user@FreeBSD.ORG Sat Jan 19 00:53:37 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 39A1A597; Sat, 19 Jan 2013 00:53:37 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 0AC95125; Sat, 19 Jan 2013 00:53:37 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0J0raew011897; Sat, 19 Jan 2013 00:53:36 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0J0raIt011896; Sat, 19 Jan 2013 00:53:36 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201301190053.r0J0raIt011896@svn.freebsd.org> From: Xin LI Date: Sat, 19 Jan 2013 00:53:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245639 - user/delphij/zfs-lz4 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Jan 2013 00:53:37 -0000 Author: delphij Date: Sat Jan 19 00:53:36 2013 New Revision: 245639 URL: http://svnweb.freebsd.org/changeset/base/245639 Log: Create a branch to dump WIP snapshot for lz4. Added: - copied from r245638, head/ Directory Properties: user/delphij/zfs-lz4/ (props changed) From owner-svn-src-user@FreeBSD.ORG Sat Jan 19 04:46:18 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id EF6E0C21; Sat, 19 Jan 2013 04:46:18 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id D4360A11; Sat, 19 Jan 2013 04:46:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0J4kIfN085192; Sat, 19 Jan 2013 04:46:18 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0J4kIS7085191; Sat, 19 Jan 2013 04:46:18 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201301190446.r0J4kIS7085191@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Sat, 19 Jan 2013 04:46:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245654 - user/ae/inet6/sys/netinet6 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Jan 2013 04:46:19 -0000 Author: ae Date: Sat Jan 19 04:46:18 2013 New Revision: 245654 URL: http://svnweb.freebsd.org/changeset/base/245654 Log: Mark SIOC*SCOPE6* ioctls as unsupported. Modified: user/ae/inet6/sys/netinet6/in6.c Modified: user/ae/inet6/sys/netinet6/in6.c ============================================================================== --- user/ae/inet6/sys/netinet6/in6.c Sat Jan 19 04:34:33 2013 (r245653) +++ user/ae/inet6/sys/netinet6/in6.c Sat Jan 19 04:46:18 2013 (r245654) @@ -359,19 +359,9 @@ in6_control(struct socket *so, u_long cm switch (cmd) { case SIOCSSCOPE6: - if (td != NULL) { - error = priv_check(td, PRIV_NETINET_SCOPE6); - if (error) - return (error); - } - return (scope6_set(ifp, - (struct scope6_id *)ifr->ifr_ifru.ifru_scope_id)); case SIOCGSCOPE6: - return (scope6_get(ifp, - (struct scope6_id *)ifr->ifr_ifru.ifru_scope_id)); case SIOCGSCOPE6DEF: - return (scope6_get_default((struct scope6_id *) - ifr->ifr_ifru.ifru_scope_id)); + return (EOPNOTSUPP); } switch (cmd) { From owner-svn-src-user@FreeBSD.ORG Sat Jan 19 05:55:19 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 0255665D; Sat, 19 Jan 2013 05:55:19 +0000 (UTC) (envelope-from alfred@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C7E81B61; Sat, 19 Jan 2013 05:55:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0J5tI6e006268; Sat, 19 Jan 2013 05:55:18 GMT (envelope-from alfred@svn.freebsd.org) Received: (from alfred@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0J5tIPt006267; Sat, 19 Jan 2013 05:55:18 GMT (envelope-from alfred@svn.freebsd.org) Message-Id: <201301190555.r0J5tIPt006267@svn.freebsd.org> From: Alfred Perlstein Date: Sat, 19 Jan 2013 05:55:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245657 - user/alfred/ewatchdog X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Jan 2013 05:55:19 -0000 Author: alfred Date: Sat Jan 19 05:55:18 2013 New Revision: 245657 URL: http://svnweb.freebsd.org/changeset/base/245657 Log: Branch for watchdogd enhancements. Added: - copied from r245656, head/ Directory Properties: user/alfred/ewatchdog/ (props changed) From owner-svn-src-user@FreeBSD.ORG Sat Jan 19 06:04:27 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 873668E9; Sat, 19 Jan 2013 06:04:27 +0000 (UTC) (envelope-from alfred@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 75699C1A; Sat, 19 Jan 2013 06:04:27 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0J64Rfm009300; Sat, 19 Jan 2013 06:04:27 GMT (envelope-from alfred@svn.freebsd.org) Received: (from alfred@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0J64RbW009298; Sat, 19 Jan 2013 06:04:27 GMT (envelope-from alfred@svn.freebsd.org) Message-Id: <201301190604.r0J64RbW009298@svn.freebsd.org> From: Alfred Perlstein Date: Sat, 19 Jan 2013 06:04:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245658 - user/alfred/ewatchdog/usr.sbin/watchdogd X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Jan 2013 06:04:27 -0000 Author: alfred Date: Sat Jan 19 06:04:26 2013 New Revision: 245658 URL: http://svnweb.freebsd.org/changeset/base/245658 Log: Add code to watchdog to time the watchdog command program, carp when the program takes too long. The purpose of this is to allow system integrators to tune their watchdogs and get advanced notice if they are behaving poorly. The following facilities are added: - Warn if the watchdog program takes too long. - Disable activation of the system watchdog so that one can test the watchdogd script without potentially rebooting the system. - Ability to log to syslog when scripts begin to timeout. The following changes are included: - When told to measure time, do not unconditionally nap for 'sleep' seconds, instead adjust the naptime by the elapsed time so as not to trigger the watchdog. Example: /usr/trees/head/usr.sbin/watchdogd # ./watchdogd -d -n -w -e "sleep 1" watchdogd: mlockall failed: Cannot allocate memory watchdogd: Watchdog program: 'sleep 1' took too long: 1.010894 seconds >= 1 seconds threshhold watchdogd: Watchdog program: 'sleep 1' took too long: 1.010636 seconds >= 1 seconds threshhold watchdogd: Watchdog program: 'sleep 1' took too long: 1.010700 seconds >= 1 seconds threshhold ^C /usr/trees/head/usr.sbin/watchdogd # ./watchdogd -d -n -w -e "sleep 0.9" watchdogd: mlockall failed: Cannot allocate memory ... doesn't complain ... Modified: user/alfred/ewatchdog/usr.sbin/watchdogd/watchdogd.8 user/alfred/ewatchdog/usr.sbin/watchdogd/watchdogd.c Modified: user/alfred/ewatchdog/usr.sbin/watchdogd/watchdogd.8 ============================================================================== --- user/alfred/ewatchdog/usr.sbin/watchdogd/watchdogd.8 Sat Jan 19 05:55:18 2013 (r245657) +++ user/alfred/ewatchdog/usr.sbin/watchdogd/watchdogd.8 Sat Jan 19 06:04:26 2013 (r245658) @@ -33,11 +33,12 @@ .Nd watchdog daemon .Sh SYNOPSIS .Nm -.Op Fl d +.Op Fl dnw .Op Fl e Ar cmd .Op Fl I Ar file .Op Fl s Ar sleep .Op Fl t Ar timeout +.Op Fl T Ar script_timeout .Sh DESCRIPTION The .Nm @@ -62,6 +63,13 @@ is not specified, the daemon will perfor check instead. .Pp The +.Fl n +argument 'dry-run' will cause watchdog not to arm the system watchdog and +instead only run the watchdog function and report on failures. +This is useful for developing new watchdogd scripts as the system will not +reboot if there are problems with the script. +.Pp +The .Fl s Ar sleep argument can be used to control the sleep period between each execution of the check and defaults to one second. @@ -78,6 +86,16 @@ If this occurs, will no longer execute and thus the kernel's watchdog routines will take action after a configurable timeout. .Pp +The +.Fl T Ar script_timeout +specifies the threshold (in seconds) at which the watchdogd will complain +that its script has run for too long. +If unset +.Ar script_timeout +defaults to the value specified by the +.Fl s Ar sleep +option. +.Pp Upon receiving the .Dv SIGTERM or @@ -100,6 +118,11 @@ Do not fork. When this option is specified, .Nm will not fork into the background at startup. +.Pp +.It Fl w +Complain when the watchdog script takes too long. +This flag will cause watchdogd to complain when the amount of time to +execute the watchdog script exceeds the threshold of 'sleep' option. .El .Sh FILES .Bl -tag -width ".Pa /var/run/watchdogd.pid" -compact Modified: user/alfred/ewatchdog/usr.sbin/watchdogd/watchdogd.c ============================================================================== --- user/alfred/ewatchdog/usr.sbin/watchdogd/watchdogd.c Sat Jan 19 05:55:18 2013 (r245657) +++ user/alfred/ewatchdog/usr.sbin/watchdogd/watchdogd.c Sat Jan 19 06:04:26 2013 (r245658) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include static void parseargs(int, char *[]); @@ -66,8 +67,14 @@ static const char *pidfile = _PATH_VARRU static u_int timeout = WD_TO_16SEC; static u_int passive = 0; static int is_daemon = 0; +static int is_dry_run = 0; /* do not arm the watchdog, only + report on timing of the watch + program */ +static int do_timedog = 0; +static int do_syslog = 0; static int fd = -1; static int nap = 1; +static int carp_thresh_seconds = -1; static char *test_cmd = NULL; /* @@ -85,12 +92,18 @@ main(int argc, char *argv[]) parseargs(argc, argv); + if (do_syslog) { + openlog("watchdogd", LOG_CONS|LOG_NDELAY|LOG_PERROR, + LOG_DAEMON); + + } + rtp.type = RTP_PRIO_REALTIME; rtp.prio = 0; if (rtprio(RTP_SET, 0, &rtp) == -1) err(EX_OSERR, "rtprio"); - if (watchdog_init() == -1) + if (!is_dry_run && watchdog_init() == -1) errx(EX_SOFTWARE, "unable to initialize watchdog"); if (is_daemon) { @@ -156,6 +169,9 @@ static int watchdog_init(void) { + if (is_dry_run) + return 0; + fd = open("/dev/" _PATH_WATCHDOG, O_RDWR); if (fd >= 0) return (0); @@ -164,26 +180,98 @@ watchdog_init(void) } /* + * If we are doing timing, then get the time. + */ +static int +watchdog_getuptime(struct timespec *tp) +{ + int error; + + if (!do_timedog) + return 0; + + error = clock_gettime(CLOCK_UPTIME_FAST, tp); + if (error) + warn("clock_gettime"); + return (error); +} + +static long +watchdog_check_dogfunction_time(struct timespec *tp_start, + struct timespec *tp_end) +{ + struct timeval tv_start, tv_end, tv; + const char *cmd_prefix, *cmd; + int sec; + + if (!do_timedog) + return (0); + + TIMESPEC_TO_TIMEVAL(&tv_start, tp_start); + TIMESPEC_TO_TIMEVAL(&tv_end, tp_end); + timersub(&tv_end, &tv_start, &tv); + sec = tv.tv_sec; + if (sec < carp_thresh_seconds) + return (sec); + + if (test_cmd) { + cmd_prefix = "Watchdog program"; + cmd = test_cmd; + } else { + cmd_prefix = "Watchdog operation"; + cmd = "stat(\"/etc\", &sb)"; + } + if (do_syslog) + syslog(LOG_CRIT, "%s: '%s' took too long: " + "%d.%06ld seconds >= %d seconds threshhold", + cmd_prefix, cmd, sec, (long)tv.tv_usec, + carp_thresh_seconds); + warnx("%s: '%s' took too long: " + "%d.%06ld seconds >= %d seconds threshhold", + cmd_prefix, cmd, sec, (long)tv.tv_usec, carp_thresh_seconds); + return (sec); +} + + +/* * Main program loop which is iterated every second. */ static void watchdog_loop(void) { + struct timespec ts_start, ts_end; struct stat sb; - int failed; + long waited; + int error, failed; while (end_program != 2) { failed = 0; + error = watchdog_getuptime(&ts_start); + if (error) { + end_program = 1; + goto try_end; + } + if (test_cmd != NULL) failed = system(test_cmd); else failed = stat("/etc", &sb); + error = watchdog_getuptime(&ts_end); + if (error) { + end_program = 1; + goto try_end; + } + + waited = watchdog_check_dogfunction_time(&ts_start, &ts_end); + if (failed == 0) watchdog_patpat(timeout|WD_ACTIVE); - sleep(nap); + if (nap - waited > 0) + sleep(nap - waited); +try_end: if (end_program != 0) { if (watchdog_onoff(0) == 0) { end_program = 2; @@ -203,6 +291,9 @@ static int watchdog_patpat(u_int t) { + if (is_dry_run) + return 0; + return ioctl(fd, WDIOCPATPAT, &t); } @@ -214,6 +305,10 @@ static int watchdog_onoff(int onoff) { + /* fake successful watchdog op if a dry run */ + if (is_dry_run) + return 0; + if (onoff) return watchdog_patpat((timeout|WD_ACTIVE)); else @@ -227,12 +322,26 @@ static void usage(void) { if (is_daemon) - fprintf(stderr, "usage: watchdogd [-d] [-e cmd] [-I file] [-s sleep] [-t timeout]\n"); + fprintf(stderr, "usage: watchdogd [-dnw] [-e cmd] [-I file] [-s sleep] [-t timeout] [-T script_timeout]\n"); else fprintf(stderr, "usage: watchdog [-d] [-t timeout]\n"); exit(EX_USAGE); } +static long +fetchtimeout(int opt, const char *myoptarg) +{ + char *p; + long rv; + + p = NULL; + errno = 0; + rv = strtol(myoptarg, &p, 0); + if ((p != NULL && *p != '\0') || errno != 0) + errx(EX_USAGE, "-%c argument is not a number", opt); + return (rv); +} + /* * Handle the few command line arguments supported. */ @@ -247,7 +356,7 @@ parseargs(int argc, char *argv[]) if (argv[0][c - 1] == 'd') is_daemon = 1; while ((c = getopt(argc, argv, - is_daemon ? "I:de:s:t:?" : "dt:?")) != -1) { + is_daemon ? "I:de:ns:t:ST:w?" : "dt:?")) != -1) { switch (c) { case 'I': pidfile = optarg; @@ -258,17 +367,19 @@ parseargs(int argc, char *argv[]) case 'e': test_cmd = strdup(optarg); break; + case 'n': + is_dry_run = 1; + break; #ifdef notyet case 'p': passive = 1; break; #endif case 's': - p = NULL; - errno = 0; - nap = strtol(optarg, &p, 0); - if ((p != NULL && *p != '\0') || errno != 0) - errx(EX_USAGE, "-s argument is not a number"); + nap = fetchtimeout(c, optarg); + break; + case 'S': + do_syslog = 1; break; case 't': p = NULL; @@ -286,12 +397,22 @@ parseargs(int argc, char *argv[]) printf("Timeout is 2^%d nanoseconds\n", timeout); break; + case 'T': + carp_thresh_seconds = fetchtimeout(c, optarg); + break; + case 'w': + do_timedog = 1; + break; case '?': default: usage(); /* NOTREACHED */ } } + + if (carp_thresh_seconds == -1) + carp_thresh_seconds = nap; + if (argc != optind) errx(EX_USAGE, "extra arguments."); if (is_daemon && timeout < WD_TO_1SEC) From owner-svn-src-user@FreeBSD.ORG Sat Jan 19 08:10:06 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 3DAD52E4; Sat, 19 Jan 2013 08:10:06 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 313062F; Sat, 19 Jan 2013 08:10:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0J8A6iI045887; Sat, 19 Jan 2013 08:10:06 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0J8A6eI045886; Sat, 19 Jan 2013 08:10:06 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201301190810.r0J8A6eI045886@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Sat, 19 Jan 2013 08:10:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r245668 - user/ae/inet6/sys/netinet6 X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Jan 2013 08:10:06 -0000 Author: ae Date: Sat Jan 19 08:10:05 2013 New Revision: 245668 URL: http://svnweb.freebsd.org/changeset/base/245668 Log: Remove sa6_recoverscope calls. Modified: user/ae/inet6/sys/netinet6/in6_pcb.c Modified: user/ae/inet6/sys/netinet6/in6_pcb.c ============================================================================== --- user/ae/inet6/sys/netinet6/in6_pcb.c Sat Jan 19 07:07:05 2013 (r245667) +++ user/ae/inet6/sys/netinet6/in6_pcb.c Sat Jan 19 08:10:05 2013 (r245668) @@ -449,15 +449,13 @@ in6_sockaddr(in_port_t port, struct in6_ { struct sockaddr_in6 *sin6; - sin6 = malloc(sizeof *sin6, M_SONAME, M_WAITOK); - bzero(sin6, sizeof *sin6); + sin6 = malloc(sizeof(*sin6), M_SONAME, M_WAITOK | M_ZERO); sin6->sin6_family = AF_INET6; sin6->sin6_len = sizeof(*sin6); sin6->sin6_port = port; sin6->sin6_addr = *addr_p; - (void)sa6_recoverscope(sin6); /* XXX: should catch errors */ - return (struct sockaddr *)sin6; + return ((struct sockaddr *)sin6); } struct sockaddr * @@ -1201,7 +1199,5 @@ init_sin6(struct sockaddr_in6 *sin6, str sin6->sin6_family = AF_INET6; sin6->sin6_addr = ip->ip6_src; - (void)sa6_recoverscope(sin6); /* XXX: should catch errors... */ - return; }