Skip to contentSkip to conversation

net: split IP_TCP header into separate IP/IP6 and TCP headers

PATCH In review Dmitrii Merkurev 2 participants 8 messages Jul 25, 2023 – Nov 8, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/6 net: split IP_TCP header into separate IP/IP6 and TCP headers

This allows us to reuse TCP logic between IP and IP6 stack.

Cc Ying-Chun Liu (PaulLiu) <[email protected]>
Cc Simon Glass <[email protected]>

Сс: Joe Hershberger <[email protected]>
Сс: Ramon Fried <[email protected]>

---
 include/net/tcp.h | 54 ++++++++++++++++--------------------
 net/tcp.c         | 70 +++++++++++++++++++++++------------------------
 test/cmd/wget.c   | 48 ++++++++++++++++++--------------
 3 files changed, 85 insertions(+), 87 deletions(-)
include/net/tcp.h +23 -31
index c29d4ce24a..93ed728dfe 100644
@@ -5,20 +5,16 @@
  * Copyright 2017 Duncan Hare, All rights reserved.
  */
 
+#ifndef __TCP_H__
+#define __TCP_H__
+
 #define TCP_ACTIVITY 127		/* Number of packets received   */
 					/* before console progress mark */
+
+#define GET_TCP_HDR_LEN_IN_BYTES(x) ((x) >> 2)
+
 /**
- * struct ip_tcp_hdr - IP and TCP header
- * @ip_hl_v: header length and version
- * @ip_tos: type of service
- * @ip_len: total length
- * @ip_id: identification
- * @ip_off: fragment offset field
- * @ip_ttl: time to live
- * @ip_p: protocol
- * @ip_sum: checksum
- * @ip_src: Source IP address
- * @ip_dst: Destination IP address
+ * struct tcp_hdr - TCP header
  * @tcp_src: TCP source port
  * @tcp_dst: TCP destination port
  * @tcp_seq: TCP sequence number
@@ -28,18 +24,8 @@
  * @tcp_win: TCP windows size
  * @tcp_xsum: Checksum
  * @tcp_ugr: Pointer to urgent data
- */
-struct ip_tcp_hdr {
-	u8		ip_hl_v;
-	u8		ip_tos;
-	u16		ip_len;
-	u16		ip_id;
-	u16		ip_off;
-	u8		ip_ttl;
-	u8		ip_p;
-	u16		ip_sum;
-	struct in_addr	ip_src;
-	struct in_addr	ip_dst;
+*/
+struct tcp_hdr {
 	u16		tcp_src;
 	u16		tcp_dst;
 	u32		tcp_seq;
@@ -51,8 +37,8 @@ struct ip_tcp_hdr {
 	u16		tcp_ugr;
 } __packed;
 
-#define IP_TCP_HDR_SIZE		(sizeof(struct ip_tcp_hdr))
-#define TCP_HDR_SIZE		(IP_TCP_HDR_SIZE  - IP_HDR_SIZE)
+#define TCP_HDR_SIZE		(sizeof(struct tcp_hdr))
+#define IP_TCP_HDR_SIZE         (IP_HDR_SIZE + TCP_HDR_SIZE)
 
 #define TCP_DATA	0x00	/* Data Packet - internal use only	*/
 #define TCP_FIN		0x01	/* Finish flag				*/
@@ -178,7 +164,8 @@ struct tcp_t_opt {
 
 /**
  * struct ip_tcp_hdr_o - IP + TCP header + TCP options
- * @hdr: IP + TCP header
+ * @ip_hdr: IP + TCP header
+ * @tcp_hdr: TCP header
  * @mss: TCP MSS Option
  * @scale: TCP Windows Scale Option
  * @sack_p: TCP Sack-Permitted Option
@@ -186,7 +173,8 @@ struct tcp_t_opt {
  * @end: end of options
  */
 struct ip_tcp_hdr_o {
-	struct	ip_tcp_hdr hdr;
+	struct	ip_hdr     ip_hdr;
+	struct	tcp_hdr    tcp_hdr;
 	struct	tcp_mss	   mss;
 	struct	tcp_scale  scale;
 	struct	tcp_sack_p sack_p;
@@ -198,15 +186,17 @@ struct ip_tcp_hdr_o {
 
 /**
  * struct ip_tcp_hdr_s - IP + TCP header + TCP options
- * @hdr: IP + TCP header
+ * @ip_hdr: IP + TCP header
+ * @tcp_hdr: TCP header
  * @t_opt: TCP Timestamp Option
  * @sack_v: TCP SACK Option
  * @end: end of options
  */
 struct ip_tcp_hdr_s {
-	struct	ip_tcp_hdr	hdr;
-	struct	tcp_t_opt	t_opt;
-	struct	tcp_sack_v	sack_v;
+	struct	ip_hdr     ip_hdr;
+	struct	tcp_hdr    tcp_hdr;
+	struct	tcp_t_opt  t_opt;
+	struct	tcp_sack_v sack_v;
 	u8	end;
 } __packed;
 
@@ -303,3 +293,5 @@ void rxhand_tcp_f(union tcp_build_pkt *b, unsigned int len);
 
 u16 tcp_set_pseudo_header(uchar *pkt, struct in_addr src, struct in_addr dest,
 			  int tcp_len, int pkt_len);
+
+#endif // __TCP_H__
net/tcp.c +35 -35

176 lines not on this page · raw message

test/cmd/wget.c +27 -21

104 lines not on this page · raw message

Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#1 lore raw

PATCH v3 2/6 net: prepare existing TCP stack to be reused by IP6

Changes:
1. Separate reusable part from net_set_tcp_header to net_set_tcp_header_common
2. Make TCP signatures reusable by receiving particular IP agnostic TCP headers
3. Extract net_send_ip_packet6 from net_send_udp_packet6 to reuse the code
4. Expose TCP state machine related functions

This allows us to reuse TCP logic between IP and IP6 stack.

Cc Ying-Chun Liu (PaulLiu) <[email protected]>
Cc Simon Glass <[email protected]>

Сс: Joe Hershberger <[email protected]>
Сс: Ramon Fried <[email protected]>

---
 include/net.h     |  26 +++-
 include/net/tcp.h | 109 +++++++++++++--
 net/net.c         |  24 ++--
 net/tcp.c         | 337 ++++++++++++++++++++++++++++------------------
 4 files changed, 342 insertions(+), 154 deletions(-)
include/net.h +22 -4
index e254df7d7f..2e19d9defc 100644
@@ -569,11 +569,29 @@ int net_eth_hdr_size(void);
 int net_set_ether(uchar *xet, const uchar *dest_ethaddr, uint prot);
 int net_update_ether(struct ethernet_hdr *et, uchar *addr, uint prot);
 
-/* Set IP header */
-void net_set_ip_header(uchar *pkt, struct in_addr dest, struct in_addr source,
+/**
+ * net_set_ip_header() - Initialize IP header for the given packet
+ *
+ * @pkt_ip_hdr: Pointer to IP header
+ * @dest:       IPv4 destination address
+ * @source:     IPv4 source address
+ * @pkt_len:    Length of ip_header + tcp_header + payload
+ * @proto:      Transport level protocol (e.g tcp/udp/etc)
+ */
+void net_set_ip_header(uchar *pkt_ip_hdr, struct in_addr dest, struct in_addr source,
 		       u16 pkt_len, u8 proto);
-void net_set_udp_header(uchar *pkt, struct in_addr dest, int dport,
-				int sport, int len);
+
+/**
+ * net_set_udp_header() - Initialize IP and UDP header for the given packet
+ *
+ * @pkt_ip_hdr: Pointer to IP header
+ * @dest:       IPv4 destination address
+ * @dport:      Destination port
+ * @sport:      Source port
+ * @len:        Payload length
+ */
+void net_set_udp_header(uchar *pkt_ip_hdr, struct in_addr dest, int dport,
+			int sport, int len);
 
 /**
  * compute_ip_checksum() - Compute IP checksum
include/net/tcp.h +99 -10

163 lines not on this page · raw message

net/net.c +16 -8
index 43abbac7c3..75a2bbaee3 100644
@@ -914,8 +914,13 @@ int net_send_ip_packet(uchar *ether, struct in_addr dest, int dport, int sport,
 		       int payload_len, int proto, u8 action, u32 tcp_seq_num,
 		       u32 tcp_ack_num)
 {
+	if ((proto == IPPROTO_UDP && !IS_ENABLED(CONFIG_PROT_UDP)) ||
+	    (proto == IPPROTO_TCP && !IS_ENABLED(CONFIG_PROT_TCP)))
+		return -EINVAL;
+
 	uchar *pkt;
 	int eth_hdr_size;
+	int ip_tcp_hdr_size;
 	int pkt_hdr_size;
 
 	/* make sure the net_tx_packet is initialized (net_init() was called) */
@@ -934,21 +939,24 @@ int net_send_ip_packet(uchar *ether, struct in_addr dest, int dport, int sport,
 	pkt = (uchar *)net_tx_packet;
 
 	eth_hdr_size = net_set_ether(pkt, ether, PROT_IP);
+	pkt_hdr_size = eth_hdr_size;
+	pkt += eth_hdr_size;
 
 	switch (proto) {
 	case IPPROTO_UDP:
-		net_set_udp_header(pkt + eth_hdr_size, dest, dport, sport,
+		net_set_udp_header(pkt, dest, dport, sport,
 				   payload_len);
-		pkt_hdr_size = eth_hdr_size + IP_UDP_HDR_SIZE;
+		pkt_hdr_size += IP_UDP_HDR_SIZE;
 		break;
-#if defined(CONFIG_PROT_TCP)
 	case IPPROTO_TCP:
-		pkt_hdr_size = eth_hdr_size
-			+ tcp_set_tcp_header(pkt + eth_hdr_size, dport, sport,
-					     payload_len, action, tcp_seq_num,
-					     tcp_ack_num);
+		ip_tcp_hdr_size = IP_HDR_SIZE;
+		ip_tcp_hdr_size += net_set_tcp_header(pkt, dport, sport,
+						      payload_len, action, tcp_seq_num,
+						      tcp_ack_num);
+		net_set_ip_header(pkt, net_server_ip, net_ip,
+				  ip_tcp_hdr_size + payload_len, IPPROTO_TCP);
+		pkt_hdr_size += ip_tcp_hdr_size;
 		break;
-#endif
 	default:
 		return -EINVAL;
 	}
net/tcp.c +205 -132

495 lines not on this page · raw message

Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#2 lore raw

PATCH v3 3/6 net: introduce TCP/IP6 support

In reply to Dmitrii Merkurev

Add TCP/IP6 related headers and reuse refactored TCP/IP implementation

Cc Ying-Chun Liu (PaulLiu) <[email protected]>
Cc Simon Glass <[email protected]>

Сс: Joe Hershberger <[email protected]>
Сс: Ramon Fried <[email protected]>

---
 include/net/tcp6.h | 103 ++++++++++++++++++++++++++++++++++
 include/net6.h     |  21 +++++++
 net/Makefile       |   1 +
 net/net.c          |   7 ++-
 net/net6.c         | 134 +++++++++++++++++++++++++++++++++++----------
 net/tcp6.c         |  97 ++++++++++++++++++++++++++++++++
 6 files changed, 332 insertions(+), 31 deletions(-)
 create mode 100644 include/net/tcp6.h
 create mode 100644 net/tcp6.c
include/net/tcp6.h new file +103 -0
new file mode 100644
index 0000000000..682480cdb4
@@ -0,0 +1,103 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ */
+
+#ifndef __TCP6_H__
+#define __TCP6_H__
+
+#include <net6.h>
+#include <net/tcp.h>
+
+/**
+ * typedef rxhand_tcp6_f() - An incoming TCP IPv6 packet handler.
+ * @pkt: pointer to the application packet
+ * @dport: destination TCP port
+ * @sip: source IP6 address
+ * @sport: source TCP port
+ * @tcp_seq_num: TCP sequential number
+ * @tcp_ack_num: TCP acknowledgment number
+ * @action: TCP packet type (SYN, ACK, FIN, etc)
+ */
+typedef void rxhand_tcp6_f(uchar *pkt, u16 dport,
+			   struct in6_addr sip, u16 sport,
+			   u32 tcp_seq_num, u32 tcp_ack_num,
+			   u8 action, unsigned int len);
+
+/**
+ * struct ip6_tcp_hdr_o - IP6 + TCP header + TCP options
+ * @ip_hdr: IP6 + TCP header
+ * @tcp_hdr: TCP header
+ * @tcp_o: TCP options
+ * @end: end of IP6/TCP header
+ */
+struct ip6_tcp_hdr_o {
+	struct  ip6_hdr    ip_hdr;
+	struct  tcp_hdr    tcp_hdr;
+	struct  tcp_hdr_o  tcp_o;
+	u8	end;
+} __packed;
+
+#define IP6_TCP_O_SIZE (sizeof(struct ip6_tcp_hdr_o))
+
+/**
+ * struct ip6_tcp_hdr_s - IP6 + TCP header + TCP options
+ * @ip_hdr: IP6 + TCP header
+ * @tcp_hdr: TCP header
+ * @t_opt: TCP Timestamp Option
+ * @sack_v: TCP SACK Option
+ * @end: end of options
+ */
+struct ip6_tcp_hdr_s {
+	struct  ip6_hdr    ip_hdr;
+	struct  tcp_hdr    tcp_hdr;
+	struct  tcp_t_opt  t_opt;
+	struct  tcp_sack_v sack_v;
+	u8	end;
+} __packed;
+
+#define IP6_TCP_SACK_SIZE (sizeof(struct ip6_tcp_hdr_s))
+
+/**
+ * union tcp6_build_pkt - union for building TCP/IP6 packet.
+ * @ip: IP6 and TCP header plus TCP options
+ * @sack: IP6 and TCP header plus SACK options
+ * @raw: buffer
+ */
+union tcp6_build_pkt {
+	struct ip6_tcp_hdr_o ip;
+	struct ip6_tcp_hdr_s sack;
+	uchar  raw[1600];
+} __packed;
+
+/**
+ * net_set_tcp6_handler6() - set application TCP6 packet handler
+ * @param f pointer to callback function
+ */
+void net_set_tcp_handler6(rxhand_tcp6_f *f);
+
+/**
+ * net_set_tcp_header6() - IPv6 TCP header bulding implementation
+ * @pkt_ip_hdr: pointer to IP6 header
+ * @dport: destination TCP port
+ * @sport: source TCP port
+ * @payload_len: payload length
+ * @action: TCP packet type (SYN, ACK, FIN, etc)
+ * @tcp_seq_num: TCP sequential number
+ * @tcp_ack_num: TCP acknowledgment number
+ *
+ * returns TCP header size
+ */
+int net_set_tcp_header6(uchar *pkt_ip_hdr, u16 dport, u16 sport, int payload_len,
+			u8 action, u32 tcp_seq_num, u32 tcp_ack_num);
+
+void net_set_tcp_handler6(rxhand_tcp6_f *f);
+
+/**
+ * rxhand_tcp6() - handle incoming IP6 TCP packet
+ * @param b pointer to IP6/TCP packet builder struct
+ * @param len full packet length
+ */
+void rxhand_tcp6(union tcp6_build_pkt *b, unsigned int len);
+
+#endif // __TCP6_H__
include/net6.h +21 -0
index beafc05338..80f9723a05 100644
@@ -344,6 +344,20 @@ int ip6_add_hdr(uchar *xip, struct in6_addr *src, struct in6_addr *dest,
 int net_send_udp_packet6(uchar *ether, struct in6_addr *dest, int dport,
 			 int sport, int len);
 
+/**
+ * net_send_tcp_packet6() - Make up TCP packet and send it
+ *
+ * @payload_len: TCP payload length
+ * @dport:	 destination port
+ * @sport:	 source port
+ * @action:	 TCP flag (SYN, ACL, PUSH, etc)
+ * @tcp_seq_num: TCP sequence number
+ * @tcp_ack_num: TCP ackno
+ * Return: 0 if send successfully, -1 otherwise
+ */
+int net_send_tcp_packet6(int payload_len, int dport, int sport, u8 action,
+			 u32 tcp_seq_num, u32 tcp_ack_num);
+
 /**
  * net_ip6_handler() - Handle IPv6 packet
  *
@@ -432,6 +446,13 @@ net_send_udp_packet6(uchar *ether, struct in6_addr *dest,
 	return -1;
 }
 
+static inline int
+net_send_tcp_packet6(int payload_len, int dport, int sport, u8 action,
+		     u32 tcp_seq_num, u32 tcp_ack_num)
+{
+	return -1;
+}
+
 static inline int
 net_ip6_handler(struct ethernet_hdr *et, struct ip6_hdr *ip6,
 		int len)
net/Makefile +1 -0
index 3e2d061338..002b0f68a2 100644
@@ -32,6 +32,7 @@ obj-$(CONFIG_TCP_FUNCTION_FASTBOOT)  += fastboot_tcp.o
 obj-$(CONFIG_CMD_WOL)  += wol.o
 obj-$(CONFIG_PROT_UDP) += udp.o
 obj-$(CONFIG_PROT_TCP) += tcp.o
+obj-$(CONFIG_IPV6) += tcp6.o
 obj-$(CONFIG_CMD_WGET) += wget.o
 
 # Disable this warning as it is triggered by:
net/net.c +5 -2
index 75a2bbaee3..468f7d924f 100644
@@ -92,6 +92,7 @@
 #include <log.h>
 #include <net.h>
 #include <net6.h>
+#include <net/tcp6.h>
 #include <ndisc.h>
 #include <net/fastboot_udp.h>
 #include <net/fastboot_tcp.h>
@@ -386,6 +387,8 @@ static void net_clear_handlers(void)
 	net_set_udp_handler(NULL);
 	net_set_arp_handler(NULL);
 	net_set_timeout_handler(0, NULL);
+	if (IS_ENABLED(CONFIG_IPV6) && IS_ENABLED(CONFIG_PROT_TCP))
+		net_set_tcp_handler6(NULL);
 }
 
 static void net_cleanup_loop(void)
@@ -1644,10 +1647,10 @@ int net_update_ether(struct ethernet_hdr *et, uchar *addr, uint prot)
 	}
 }
 
-void net_set_ip_header(uchar *pkt, struct in_addr dest, struct in_addr source,
+void net_set_ip_header(uchar *pkt_ip_hdr, struct in_addr dest, struct in_addr source,
 		       u16 pkt_len, u8 proto)
 {
-	struct ip_udp_hdr *ip = (struct ip_udp_hdr *)pkt;
+	struct ip_udp_hdr *ip = (struct ip_udp_hdr *)pkt_ip_hdr;
 
 	/*
 	 *	Construct an IP header.
net/net6.c +105 -29

188 lines not on this page · raw message

net/tcp6.c new file +97 -0

97 lines not on this page · raw message

Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#3 lore raw

PATCH v3 4/6 net: add fastboot TCP6 support

In reply to Dmitrii Merkurev

fastboot tcp command remains the same, but started listening IP6 in case it's enabled

Cc Ying-Chun Liu (PaulLiu) <[email protected]>
Cc Simon Glass <[email protected]>

Сс: Joe Hershberger <[email protected]>
Сс: Ramon Fried <[email protected]>

---
 include/net/fastboot_tcp.h |  2 +-
 net/fastboot_tcp.c         | 69 ++++++++++++++++++++++++++++++++------
 2 files changed, 59 insertions(+), 12 deletions(-)
include/net/fastboot_tcp.h +1 -1
index 6cf29d52e9..98986fa10a 100644
@@ -7,7 +7,7 @@
 #define __NET_FASTBOOT_TCP_H__
 
 /**
- * Wait for incoming tcp fastboot comands.
+ * Wait for incoming TCP fastboot comands.
  */
 void fastboot_tcp_start_server(void);
 
net/fastboot_tcp.c +58 -11

143 lines not on this page · raw message

Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#4 lore raw

PATCH v3 5/6 net: add fastboot TCP documentation and IP6-only mode

In reply to Dmitrii Merkurev

Command to start IPv6 only TCP fastboot:
fastboot tcp -ipv6

Cc Ying-Chun Liu (PaulLiu) <[email protected]>
Cc Simon Glass <[email protected]>

Сс: Joe Hershberger <[email protected]>
Сс: Ramon Fried <[email protected]>

---
 cmd/fastboot.c             | 29 ++++++++++++++++++++++++----
 doc/android/fastboot.rst   | 13 +++++++++++--
 doc/usage/cmd/fastboot.rst | 39 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+), 6 deletions(-)
 create mode 100644 doc/usage/cmd/fastboot.rst
cmd/fastboot.c +25 -4
index 3d5ff951eb..36f744ae01 100644
@@ -12,6 +12,7 @@
 #include <g_dnl.h>
 #include <fastboot.h>
 #include <net.h>
+#include <net6.h>
 #include <usb.h>
 #include <watchdog.h>
 #include <linux/stringify.h>
@@ -121,10 +122,23 @@ static int do_fastboot(struct cmd_tbl *cmdtp, int flag, int argc,
 {
 	uintptr_t buf_addr = (uintptr_t)NULL;
 	size_t buf_size = 0;
+	bool is_ipv6_only = false;
+	bool is_usb = false;
+	bool is_udp = false;
+	bool is_tcp = false;
 
 	if (argc < 2)
 		return CMD_RET_USAGE;
 
+	if (IS_ENABLED(CONFIG_IPV6)) {
+		use_ip6 = false;
+		/* IPv6 parameter has to be always *last* */
+		if (!strcmp(argv[argc - 1], USE_IP6_CMD_PARAM)) {
+			is_ipv6_only = true;
+			--argc;
+		}
+	}
+
 	while (argc > 1 && **(argv + 1) == '-') {
 		char *arg = *++argv;
 
@@ -159,11 +173,18 @@ NXTARG:
 
 	fastboot_init((void *)buf_addr, buf_size);
 
-	if (!strcmp(argv[1], "udp"))
+	is_usb = strcmp(argv[1], "usb") == 0;
+	is_udp = strcmp(argv[1], "udp") == 0;
+	is_tcp = strcmp(argv[1], "tcp") == 0;
+
+	if (is_ipv6_only && is_tcp)
+		use_ip6 = true;
+
+	if (is_udp)
 		return do_fastboot_udp(argc, argv, buf_addr, buf_size);
-	if (!strcmp(argv[1], "tcp"))
+	if (is_tcp)
 		return do_fastboot_tcp(argc, argv, buf_addr, buf_size);
-	if (!strcmp(argv[1], "usb")) {
+	if (is_usb) {
 		argv++;
 		argc--;
 	}
@@ -174,7 +195,7 @@ NXTARG:
 U_BOOT_CMD(
 	fastboot, CONFIG_SYS_MAXARGS, 1, do_fastboot,
 	"run as a fastboot usb or udp device",
-	"[-l addr] [-s size] usb <controller> | udp\n"
+	"[-l addr] [-s size] usb <controller> | udp [-ipv6] | tcp [-ipv6]\n"
 	"\taddr - address of buffer used during data transfers ("
 	__stringify(CONFIG_FASTBOOT_BUF_ADDR) ")\n"
 	"\tsize - size of buffer used during data transfers ("
doc/android/fastboot.rst +11 -2
index 1ad8a897c8..52f955b3d2 100644
@@ -177,17 +177,26 @@ configuration options:
 In Action
 ---------
 
-Enter into fastboot by executing the fastboot command in U-Boot for either USB::
+Enter into fastboot by executing the fastboot command in U-Boot for either:
+
+USB::
 
    => fastboot usb 0
 
-or UDP::
+UDP::
 
    => fastboot udp
    link up on port 0, speed 100, full duplex
    Using ethernet@4a100000 device
    Listening for fastboot command on 192.168.0.102
 
+or TCP::
+
+   => fastboot tcp [-ipv6]
+   Using ethernet@4a100000 device
+   Listening for fastboot command on 192.168.0.102
+   Listening for fastboot command on fe80:0000:0000:0000:5054:00ff:fe12:3456
+
 On the client side you can fetch the bootloader version for instance::
 
    $ fastboot getvar version-bootloader
doc/usage/cmd/fastboot.rst new file +39 -0
new file mode 100644
index 0000000000..69c7c0e912
@@ -0,0 +1,39 @@
+.. SPDX-License-Identifier: GPL-2.0+:
+
+fastboot command
+==========
+
+Synopis
+-------
+
+::
+
+    fastboot [-l addr] [-s size] usb <controller> | udp [-ipv6] | tcp [-ipv6]
+
+Description
+-----------
+
+The *fastboot* command allows to start fastboot usb/udp/tcp server to receive
+connections from host using fastboot protocol. For more information please refer to:
+`doc/android/fastboot.rst`.
+
+Examples
+--------
+
+USB::
+
+   => fastboot usb 0
+
+UDP::
+
+   => fastboot udp [-ipv6]
+   link up on port 0, speed 100, full duplex
+   Using ethernet@4a100000 device
+   Listening for fastboot command on 192.168.0.102
+
+TCP::
+
+   => fastboot tcp [-ipv6]
+   Using ethernet@4a100000 device
+   Listening for fastboot command on 192.168.0.102
+   Listening for fastboot command on fe80:0000:0000:0000:5054:00ff:fe12:3456
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#5 lore raw

PATCH v3 6/6 net: update net_ip6 from link_local address when eth device is changed

In reply to Dmitrii Merkurev

Current active eth device may be changed (due to ethprime), so make sure current net_ip6 is updated as a reaction.

Cc Ying-Chun Liu (PaulLiu) <[email protected]>
Cc Simon Glass <[email protected]>

Сс: Joe Hershberger <[email protected]>
Сс: Ramon Fried <[email protected]>

---
 net/net.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
net/net.c +4 -4
index 468f7d924f..ae7e6cdccc 100644
@@ -359,10 +359,10 @@ static int net_init_loop(void)
 
 		if (IS_ENABLED(CONFIG_IPV6)) {
 			ip6_make_lladdr(&net_link_local_ip6, net_ethaddr);
-			if (!memcmp(&net_ip6, &net_null_addr_ip6,
-				    sizeof(struct in6_addr)))
-				memcpy(&net_ip6, &net_link_local_ip6,
-				       sizeof(struct in6_addr));
+			if (memcmp(&net_link_local_ip6, &net_null_addr_ip6,
+				   sizeof(struct in6_addr))) {
+				net_copy_ip6(&net_ip6, &net_link_local_ip6);
+			}
 		}
 	}
 	else
Signature · 1 line
2.41.0.487.g6d72f3e995-goog
#6 lore raw
In reply to Dmitrii Merkurev
Quoted 7 lines · Dmitrii Merkurev

This allows us to reuse TCP logic between IP and IP6 stack.

Cc Ying-Chun Liu (PaulLiu) <[email protected]>
Cc Simon Glass <[email protected]>

Сс: Joe Hershberger <[email protected]>
Сс: Ramon Fried <[email protected]>

Quoted 7 lines
---
 include/net/tcp.h | 54 ++++++++++++++++--------------------
 net/tcp.c         | 70 +++++++++++++++++++++++------------------------
 test/cmd/wget.c   | 48 ++++++++++++++++++--------------
 3 files changed, 85 insertions(+), 87 deletions(-)

I do want to thank you for your contribution. However, the long term goal with the project right now is to move to integrate lwip as the networking stack (and in turn have more robust IPv6 and wget and similar features). So, I don't want to pickup this series (unless you think it's still important here-and-now, given the above). I would ask you to please keep an eye on that effort and either try out v10:
https://patchwork.ozlabs.org/project/uboot/list/?series=374882&state=*
or keep an eye out for v11. Thanks again!

Signature · 1 line
Tom
#7 lore raw

Hey Tom, huge thanks for sharing that. I agree lwip is the proper way to handle this, will try out this patch set and eventually migrate fastboot apps into a new stack.

Quoted 29 lines · Tom Rini
Quoted 7 lines · Dmitrii Merkurev

This allows us to reuse TCP logic between IP and IP6 stack.

Cc Ying-Chun Liu (PaulLiu) <[email protected]>
Cc Simon Glass <[email protected]>

Сс: Joe Hershberger <[email protected]>
Сс: Ramon Fried <[email protected]>

Quoted 7 lines
---
 include/net/tcp.h | 54 ++++++++++++++++--------------------
 net/tcp.c         | 70 +++++++++++++++++++++++------------------------
 test/cmd/wget.c   | 48 ++++++++++++++++++--------------
 3 files changed, 85 insertions(+), 87 deletions(-)

I do want to thank you for your contribution. However, the long term goal with the project right now is to move to integrate lwip as the networking stack (and in turn have more robust IPv6 and wget and similar features). So, I don't want to pickup this series (unless you think it's still important here-and-now, given the above). I would ask you to please keep an eye on that effort and either try out v10:
https://patchwork.ozlabs.org/project/uboot/list/?series=374882&state=*
or keep an eye out for v11. Thanks again!

--
Tom