From patchwork Fri Dec 2 09:17:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1711308 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=hycR/4U9; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNnSn30cHz23nC for ; Fri, 2 Dec 2022 20:19:21 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6650885423; Fri, 2 Dec 2022 10:19:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="hycR/4U9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BE7928503A; Fri, 2 Dec 2022 10:18:54 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 914BF85221 for ; Fri, 2 Dec 2022 10:18:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 3D3E440889; Fri, 2 Dec 2022 09:18:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1669972725; x=1671787126; bh=xZhqW8TgRsuUzFV5WMxDlBOj8 DKHFKcvVbcI4McWeSM=; b=hycR/4U9V1d+ycuIFL03SFL5QSg1sQOHXfnDYj+sV K3991xnw78JXYt65VF2jOIdSdWpmFvnso0To1zAe0cAK81T/iFbb6RKa96CbAgfp fQhbOqt66WHNVsbjnNUHMnrJ8Z53z2cHwfN+5+9dZWGB/8H8vi9/G4wCTpnQYThT vs= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 59hbyTqjyIZb; Fri, 2 Dec 2022 12:18:45 +0300 (MSK) Received: from T-EXCH-01.corp.yadro.com (T-EXCH-01.corp.yadro.com [172.17.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 559BA4014D; Fri, 2 Dec 2022 12:18:45 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-01.corp.yadro.com (172.17.10.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 2 Dec 2022 12:18:45 +0300 Received: from v.yadro.com (10.178.114.10) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 2 Dec 2022 12:18:44 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , Subject: [PATCH v5 01/19] net: ipv6: Add IPv6 basic primitives Date: Fri, 2 Dec 2022 12:17:58 +0300 Message-ID: <20221202091818.2382748-2-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> References: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.178.114.10] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-Exch-05.corp.yadro.com (172.17.10.109) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean This patch is a collection of basic primitives that are prerequisite for further IPv6 implementation. There are structures definition such as IPv6 header, UDP header (for TFTP), ICMPv6 header. There are auxiliary defines such as protocol codes, padding, struct size and etc. Also here are functions prototypes and its empty implementation that will be used as API for further patches. Here are variables declaration such as IPv6 address of our host, gateway, ipv6 server. Series-changes: 3 - Added functions and structures descriptions - Removed enums ND_OPT_*. It will be moved into further patches - Substituted -1 for error codes Series-changes: 4 - Changed functions and structures description style Signed-off-by: Viacheslav Mitrofanov Reviewed-by: Ramon Fried Reviewed-by: Simon Glass --- include/net6.h | 369 +++++++++++++++++++++++++++++++++++++++++++++++++ net/net6.c | 31 +++++ 2 files changed, 400 insertions(+) create mode 100644 include/net6.h create mode 100644 net/net6.c diff --git a/include/net6.h b/include/net6.h new file mode 100644 index 0000000000..9200eae04e --- /dev/null +++ b/include/net6.h @@ -0,0 +1,369 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2013 Allied Telesis Labs NZ + * Chris Packham, + * + * Copyright (C) 2022 YADRO + * Viacheslav Mitrofanov + */ + +#ifndef __NET6_H__ +#define __NET6_H__ + +#include +#include + +/* struct in6_addr - 128 bits long IPv6 address */ +struct in6_addr { + union { + u8 u6_addr8[16]; + __be16 u6_addr16[8]; + __be32 u6_addr32[4]; + } in6_u; + +#define s6_addr in6_u.u6_addr8 +#define s6_addr16 in6_u.u6_addr16 +#define s6_addr32 in6_u.u6_addr32 +}; + +#define IN6ADDRSZ sizeof(struct in6_addr) +#define INETHADDRSZ sizeof(net_ethaddr) + +#define PROT_IP6 0x86DD /* IPv6 protocol */ +#define PROT_ICMPV6 58 /* ICMPv6 protocol*/ + +#define IPV6_ADDRSCOPE_INTF 0x01 +#define IPV6_ADDRSCOPE_LINK 0x02 +#define IPV6_ADDRSCOPE_AMDIN 0x04 +#define IPV6_ADDRSCOPE_SITE 0x05 +#define IPV6_ADDRSCOPE_ORG 0x08 +#define IPV6_ADDRSCOPE_GLOBAL 0x0E + +#define USE_IP6_CMD_PARAM "-ipv6" + +/** + * struct ipv6hdr - Internet Protocol V6 (IPv6) header. + * + * IPv6 packet header as defined in RFC 2460. + */ +struct ip6_hdr { +#if defined(__LITTLE_ENDIAN_BITFIELD) + u8 priority:4, + version:4; +#elif defined(__BIG_ENDIAN_BITFIELD) + u8 version:4, + priority:4; +#else +#error "Please fix " +#endif + u8 flow_lbl[3]; + __be16 payload_len; + u8 nexthdr; + u8 hop_limit; + struct in6_addr saddr; + struct in6_addr daddr; +}; +#define IP6_HDR_SIZE (sizeof(struct ip6_hdr)) + +/* struct udp_hdr - User Datagram Protocol header */ +struct udp_hdr { + u16 udp_src; /* UDP source port */ + u16 udp_dst; /* UDP destination port */ + u16 udp_len; /* Length of UDP packet */ + u16 udp_xsum; /* Checksum */ +} __packed; + +/* + * Handy for static initialisations of struct in6_addr, atlhough the + * c99 '= { 0 }' idiom might work depending on you compiler. + */ +#define ZERO_IPV6_ADDR { { { 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00 } } } + +#define IPV6_LINK_LOCAL_PREFIX 0xfe80 + +/* hop limit for neighbour discovery packets */ +#define IPV6_NDISC_HOPLIMIT 255 +#define NDISC_TIMEOUT 5000UL +#define NDISC_TIMEOUT_COUNT 3 + +/* struct icmp6hdr - Internet Control Message Protocol header for IPV6 */ +struct icmp6hdr { + u8 icmp6_type; +#define IPV6_ICMP_ECHO_REQUEST 128 +#define IPV6_ICMP_ECHO_REPLY 129 +#define IPV6_NDISC_ROUTER_SOLICITATION 133 +#define IPV6_NDISC_ROUTER_ADVERTISEMENT 134 +#define IPV6_NDISC_NEIGHBOUR_SOLICITATION 135 +#define IPV6_NDISC_NEIGHBOUR_ADVERTISEMENT 136 +#define IPV6_NDISC_REDIRECT 137 + u8 icmp6_code; + __be16 icmp6_cksum; + + /* ICMPv6 data */ + union { + __be32 un_data32[1]; + __be16 un_data16[2]; + u8 un_data8[4]; + + /* struct icmpv6_echo - echo request/reply message format */ + struct icmpv6_echo { + __be16 identifier; + __be16 sequence; + } u_echo; + + /* struct icmpv6_nd_advt - Neighbor Advertisement format */ + struct icmpv6_nd_advt { +#if defined(__LITTLE_ENDIAN_BITFIELD) + __be32 reserved:5, + override:1, + solicited:1, + router:1, + reserved2:24; +#elif defined(__BIG_ENDIAN_BITFIELD) + __be32 router:1, + solicited:1, + override:1, + reserved:29; +#else +#error "Please fix " +#endif + } u_nd_advt; + + /* struct icmpv6_nd_ra - Router Advertisement format */ + struct icmpv6_nd_ra { + u8 hop_limit; +#if defined(__LITTLE_ENDIAN_BITFIELD) + u8 reserved:6, + other:1, + managed:1; + +#elif defined(__BIG_ENDIAN_BITFIELD) + u8 managed:1, + other:1, + reserved:6; +#else +#error "Please fix " +#endif + __be16 rt_lifetime; + } u_nd_ra; + } icmp6_dataun; +#define icmp6_identifier icmp6_dataun.u_echo.identifier +#define icmp6_sequence icmp6_dataun.u_echo.sequence +#define icmp6_pointer icmp6_dataun.un_data32[0] +#define icmp6_mtu icmp6_dataun.un_data32[0] +#define icmp6_unused icmp6_dataun.un_data32[0] +#define icmp6_maxdelay icmp6_dataun.un_data16[0] +#define icmp6_router icmp6_dataun.u_nd_advt.router +#define icmp6_solicited icmp6_dataun.u_nd_advt.solicited +#define icmp6_override icmp6_dataun.u_nd_advt.override +#define icmp6_ndiscreserved icmp6_dataun.u_nd_advt.reserved +#define icmp6_hop_limit icmp6_dataun.u_nd_ra.hop_limit +#define icmp6_addrconf_managed icmp6_dataun.u_nd_ra.managed +#define icmp6_addrconf_other icmp6_dataun.u_nd_ra.other +#define icmp6_rt_lifetime icmp6_dataun.u_nd_ra.rt_lifetime +}; + +extern struct in6_addr const net_null_addr_ip6; /* NULL IPv6 address */ +extern struct in6_addr net_gateway6; /* Our gateways IPv6 address */ +extern struct in6_addr net_ip6; /* Our IPv6 addr (0 = unknown) */ +extern struct in6_addr net_link_local_ip6; /* Our link local IPv6 addr */ +extern u32 net_prefix_length; /* Our prefixlength (0 = unknown) */ +extern struct in6_addr net_server_ip6; /* Server IPv6 addr (0 = unknown) */ +extern bool use_ip6; + +/** + * string_to_ip6() - Convert IPv6 string addr to inner IPV6 addr format + * + * Examples of valid strings: + * 2001:db8::0:1234:1 + * 2001:0db8:0000:0000:0000:0000:1234:0001 + * ::1 + * ::ffff:192.168.1.1 + * + * Examples of invalid strings + * 2001:db8::0::0 (:: can only appear once) + * 2001:db8:192.168.1.1::1 (v4 part can only appear at the end) + * 192.168.1.1 (we don't implicity map v4) + * + * @s: IPv6 string addr format + * @len: IPv6 string addr length + * @addr: converted IPv6 addr + * Return: 0 if conversion successful, -EINVAL if fail + */ +static inline int +string_to_ip6(const char *s, size_t len, struct in6_addr *addr) +{ + return -EINVAL; +} + +/** + * ip6_is_unspecified_addr() - Check if IPv6 addr is not set i.e. is zero + * + * @addr: IPv6 addr + * Return: 0 if addr is not set, -1 if is set + */ +static inline int ip6_is_unspecified_addr(struct in6_addr *addr) +{ + return -1; +} + +/** + * ip6_is_our_addr() - Check if IPv6 addr belongs to our host addr + * + * We have 2 addresses that we should respond to. A link local address and a + * global address. This returns true if the specified address matches either + * of these. + * + * @addr: addr to check + * Return: 0 if addr is our, -1 otherwise + */ +static inline int ip6_is_our_addr(struct in6_addr *addr) +{ + return -1; +} + +/** + * ip6_addr_in_subnet() - Check if two IPv6 addresses are in the same subnet + * + * @our_addr: first IPv6 addr + * @neigh_addr: second IPv6 addr + * @prefix_length: network mask length + * Return: 0 if two addresses in the same subnet, -1 otherwise + */ +static inline int +ip6_addr_in_subnet(struct in6_addr *our_addr, struct in6_addr *neigh_addr, + u32 prefix_length) +{ + return -1; +} + +/** + * ip6_make_lladd() - rMake up IPv6 Link Local address + * + * @lladdr: formed IPv6 Link Local address + * @enetaddr: MAC addr of a device + */ +static inline void +ip6_make_lladdr(struct in6_addr *lladdr, unsigned char const enetaddr[6]) +{ +} + +/** + * ip6_make_snma() - aMake up Solicited Node Multicast Address from IPv6 addr + * + * @mcast_addr: formed SNMA addr + * @ip6_addr: base IPv6 addr + */ +static inline void +ip6_make_snma(struct in6_addr *mcast_addr, struct in6_addr *ip6_addr) +{ +} + +/** + * ip6_make_mult_ethdstaddr() - Make up IPv6 multicast addr + * + * @enetaddr: MAC addr of a device + * @mcast_addr: formed IPv6 multicast addr + */ +static inline void +ip6_make_mult_ethdstaddr(unsigned char enetaddr[6], + struct in6_addr *mcast_addr) +{ +} + +/** + * csum_partial() - Compute an internet checksum + * + * @buff: buffer to be checksummed + * @len: length of buffer + * @sum: initial sum to be added in + * Return: internet checksum of the buffer + */ +static inline unsigned int +csum_partial(const unsigned char *buff, int len, unsigned int sum) +{ + return 0; +} + +/** + * csum_ipv6_magic() - Compute checksum of IPv6 "psuedo-header" per RFC2460 section 8.1 + * + * @saddr: source IPv6 addr + * @daddr: destination IPv6 add + * @len: data length to be checksumed + * @proto: IPv6 above protocol code + * @csum: upper layer checksum + * Return: computed checksum + */ +static inline unsigned short +csum_ipv6_magic(struct in6_addr *saddr, + struct in6_addr *daddr, u16 len, + unsigned short proto, unsigned int csum) +{ + return 0; +} + +/** + * ip6_add_hdr() - Make up IPv6 header + * + * @xip: pointer to IPv6 header to be formed + * @src: source IPv6 addr + * @dest: destination IPv6 addr + * @nextheader: next header type + * @hoplimit: hop limit + * @payload_len: payload length + * Return: IPv6 header length + */ +static inline unsigned int +ip6_add_hdr(uchar *xip, struct in6_addr *src, struct in6_addr *dest, + int nextheader, int hoplimit, int payload_len) +{ + return 0; +} + +/** + * net_send_udp_packet6() - Make up UDP packet and send it + * + * @ether: destination MAC addr + * @dest: destination IPv6 addr + * @dport: destination port + * @sport: source port + * @len: UDP packet length + * Return: 0 if send successfully, -1 otherwise + */ +static inline int +net_send_udp_packet6(uchar *ether, struct in6_addr *dest, + int dport, int sport, int len) +{ + return -1; +} + +/** + * net_ip6_handler() - Handle IPv6 packet + * + * @et: pointer to the begining of the packet + * @ip6: pointer to the begining of IPv6 protocol + * @len: incoming packet len + * Return: 0 if handle packet successfully, -EINVAL in case of invalid protocol + */ +static inline int +net_ip6_handler(struct ethernet_hdr *et, struct ip6_hdr *ip6, + int len) +{ + return -EINVAL; +} + +/** + * net_copy_ip6() - Copy IPv6 addr + * + * @to: destination IPv6 addr + * @from: source IPv6 addr + */ +static inline void net_copy_ip6(void *to, const void *from) +{ +} + +#endif /* __NET6_H__ */ diff --git a/net/net6.c b/net/net6.c new file mode 100644 index 0000000000..7cd442e6e2 --- /dev/null +++ b/net/net6.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2013 Allied Telesis Labs NZ + * Chris Packham, + * + * Copyright (C) 2022 YADRO + * Viacheslav Mitrofanov + */ + +/* Simple IPv6 network layer implementation */ + +#include +#include +#include +#include +#include + +/* NULL IPv6 address */ +struct in6_addr const net_null_addr_ip6 = ZERO_IPV6_ADDR; +/* Our gateway's IPv6 address */ +struct in6_addr net_gateway6 = ZERO_IPV6_ADDR; +/* Our IPv6 addr (0 = unknown) */ +struct in6_addr net_ip6 = ZERO_IPV6_ADDR; +/* Our link local IPv6 addr (0 = unknown) */ +struct in6_addr net_link_local_ip6 = ZERO_IPV6_ADDR; +/* set server IPv6 addr (0 = unknown) */ +struct in6_addr net_server_ip6 = ZERO_IPV6_ADDR; +/* The prefix length of our network */ +u32 net_prefix_length; + +bool use_ip6; From patchwork Fri Dec 2 09:17:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1711307 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=n3YplCRR; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNnSY0Bmgz23nC for ; Fri, 2 Dec 2022 20:19:09 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C797485359; Fri, 2 Dec 2022 10:18:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="n3YplCRR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5CB8985270; Fri, 2 Dec 2022 10:18:53 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 03D518535C for ; Fri, 2 Dec 2022 10:18:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 9812A4014D; Fri, 2 Dec 2022 09:18:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1669972726; x=1671787127; bh=sfXsbJgrq/gPZwliU+ig4UGnR /lrf8OJTeH9LkSa1Y4=; b=n3YplCRRJa5oXcEVB2n9cqVfl+oBVQSL0Oq6RyU9w sYY4mCZEVQ73aVM281gbyhwOeRA3r6T0IqTe6WV89RKsViUIPSTVog2f5TQQtfdf +Fv+T6ZOxapdPfuqqCLVTvS4ljWbzMwWjzxF0pzw7+qJ0VQ2DSIwtBz8oDaDmfVm O4= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2GOHt6PF43Es; Fri, 2 Dec 2022 12:18:46 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (T-EXCH-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 845B64088A; Fri, 2 Dec 2022 12:18:46 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 2 Dec 2022 12:18:46 +0300 Received: from v.yadro.com (10.178.114.10) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 2 Dec 2022 12:18:45 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , Subject: [PATCH v5 02/19] net: ipv6: Add IPv6 build options Date: Fri, 2 Dec 2022 12:17:59 +0300 Message-ID: <20221202091818.2382748-3-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> References: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.178.114.10] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-Exch-05.corp.yadro.com (172.17.10.109) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Add options to Makefile and Kconfig file to build IPv6 Series-changes: 3 - Added help for IPv6 support Signed-off-by: Viacheslav Mitrofanov Reviewed-by: Ramon Fried Reviewed-by: Simon Glass --- net/Kconfig | 10 ++++++++++ net/Makefile | 1 + 2 files changed, 11 insertions(+) diff --git a/net/Kconfig b/net/Kconfig index cb600fe5eb..a1ec3f8542 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -190,6 +190,16 @@ config PROT_TCP_SACK This option should be turn on if you want to achieve the fastest file transfer possible. +config IPV6 + bool "IPv6 support" + help + Enable IPv6 support. It includes Neighbour Discovery protocol, ICMPv6 + and auxiliary stuff to make it work. Since it is enabled u-boot + network subsystem can get and handle incoming packets and send packets + through IPv6 network. It allows to use environment variables such as + ip6addr, serverip6. If a u-boot command is capable to parse an IPv6 + address and find it, it will force using IPv6 in the network stack. + endif # if NET config SYS_RX_ETH_BUFFER diff --git a/net/Makefile b/net/Makefile index 4f757a224c..00d6f9ddf0 100644 --- a/net/Makefile +++ b/net/Makefile @@ -21,6 +21,7 @@ obj-$(CONFIG_DM_MDIO_MUX) += mdio-mux-uclass.o obj-$(CONFIG_NET) += eth_common.o obj-$(CONFIG_CMD_LINK_LOCAL) += link_local.o obj-$(CONFIG_NET) += net.o +obj-$(CONFIG_IPV6) += net6.o obj-$(CONFIG_CMD_NFS) += nfs.o obj-$(CONFIG_CMD_PING) += ping.o obj-$(CONFIG_CMD_PCAP) += pcap.o From patchwork Fri Dec 2 09:18:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1711309 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=gAdY/4OD; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNnT20tDdz23nC for ; Fri, 2 Dec 2022 20:19:33 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A2BF68543F; Fri, 2 Dec 2022 10:19:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="gAdY/4OD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5228B85221; Fri, 2 Dec 2022 10:18:55 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7E94D80759 for ; Fri, 2 Dec 2022 10:18:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 2E64241200; Fri, 2 Dec 2022 09:18:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1669972728; x=1671787129; bh=x9cAjFZo5Zl0wOCVTQNWtJi0s 1IDKHfFbEu1CJ5b4MM=; b=gAdY/4ODV4rOIsit7KuCcoNP3pjADYl+JolUFUSuW LTmv4UFMUkiIyOMbNte4b7fam9/0xfZ+0ezXDrwnz29P3kdMODFVdeqeWKubfNG5 4Hy7bNsUTOcWGSWBGVYgeYp+CHuvEvAZWzg5XOOI9AGYfUPUJat7nI3Y25Auh/rh Hc= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id M7mHPc-98WDG; Fri, 2 Dec 2022 12:18:48 +0300 (MSK) Received: from T-EXCH-01.corp.yadro.com (T-EXCH-01.corp.yadro.com [172.17.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 0FA544088A; Fri, 2 Dec 2022 12:18:48 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-01.corp.yadro.com (172.17.10.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 2 Dec 2022 12:18:47 +0300 Received: from v.yadro.com (10.178.114.10) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 2 Dec 2022 12:18:46 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , Subject: [PATCH v5 03/19] net: ipv6: Add callbacks declarations to get access to IPv6 variables Date: Fri, 2 Dec 2022 12:18:00 +0300 Message-ID: <20221202091818.2382748-4-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> References: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.178.114.10] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-Exch-05.corp.yadro.com (172.17.10.109) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Set up callbacks for main IPv6 variables ip6add, serverip6, gatewayip6 and set options to them in flag file. These variables are often set up by users. Signed-off-by: Viacheslav Mitrofanov Reviewed-by: Ramon Fried Reviewed-by: Simon Glass --- include/env_callback.h | 10 ++++++++++ include/env_flags.h | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/env_callback.h b/include/env_callback.h index 1eae0efca2..85e7fe25f8 100644 --- a/include/env_callback.h +++ b/include/env_callback.h @@ -51,6 +51,15 @@ #define NET_CALLBACKS #endif +#ifdef CONFIG_IPV6 +#define NET6_CALLBACKS \ + "ip6addr:ip6addr," \ + "serverip6:serverip6," \ + "gatewayip6:gatewayip6," +#else +#define NET6_CALLBACKS +#endif + #ifdef CONFIG_BOOTSTD #define BOOTSTD_CALLBACK "bootmeths:bootmeths," #else @@ -65,6 +74,7 @@ ENV_DOT_ESCAPE ENV_FLAGS_VAR ":flags," \ "baudrate:baudrate," \ NET_CALLBACKS \ + NET6_CALLBACKS \ BOOTSTD_CALLBACK \ "loadaddr:loadaddr," \ SILENT_CALLBACK \ diff --git a/include/env_flags.h b/include/env_flags.h index 313cb8c49a..718d72773c 100644 --- a/include/env_flags.h +++ b/include/env_flags.h @@ -67,6 +67,15 @@ enum env_flags_varaccess { #define NET_FLAGS #endif +#ifdef CONFIG_IPV6 +#define NET6_FLAGS \ + "ip6addr:s," \ + "serverip6:s," \ + "gatewayip6:s" +#else +#define NET6_FLAGS +#endif + #ifndef CONFIG_ENV_OVERWRITE #define SERIAL_FLAGS "serial#:so," #else @@ -76,6 +85,7 @@ enum env_flags_varaccess { #define ENV_FLAGS_LIST_STATIC \ ETHADDR_FLAGS \ NET_FLAGS \ + NET6_FLAGS \ SERIAL_FLAGS \ CONFIG_ENV_FLAGS_LIST_STATIC From patchwork Fri Dec 2 09:18:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1711310 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=nNZuVuRJ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNnTH0h3fz23nC for ; Fri, 2 Dec 2022 20:19:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5E25B85435; Fri, 2 Dec 2022 10:19:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="nNZuVuRJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 56F5C853DB; Fri, 2 Dec 2022 10:18:57 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6F140853BD for ; Fri, 2 Dec 2022 10:18:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 1DBDD40889; Fri, 2 Dec 2022 09:18:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1669972729; x=1671787130; bh=3Pt1Z4zDp+vWu5UXxrVf91UIt EERSsQg6ms3JHvX0v0=; b=nNZuVuRJuoKiiRBaupuEp0ZjvoF26cMR8+7h5Lqy5 IqxUw9QU5aILbl9o+5GDi6A12N6ML+bU4Ah6ulFnytDUxQQFSTt8RM/b33rrpL6R 38/06tqX+NGOU4HiDLylJGVEdHClktPjUEkICaN8blVPnaWYsq5QW0N+w1ZSimXY Eg= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id G1nF_lppJ1uY; Fri, 2 Dec 2022 12:18:49 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (T-EXCH-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 250AB411FF; Fri, 2 Dec 2022 12:18:49 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 2 Dec 2022 12:18:49 +0300 Received: from v.yadro.com (10.178.114.10) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 2 Dec 2022 12:18:48 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , Subject: [PATCH v5 04/19] net: ipv6: Add Neighbor Discovery Protocol (NDP) Date: Fri, 2 Dec 2022 12:18:01 +0300 Message-ID: <20221202091818.2382748-5-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> References: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.178.114.10] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-Exch-05.corp.yadro.com (172.17.10.109) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Implement basic of NDP. It doesn't include such things as Router Solicitation, Router Advertisement and Redirect. It just has Neighbor Solicitation and Neighbor Advertisement. Only these two features are used in u-boot IPv6. Implementation of some NDP functions uses API that was exposed in "net: ipv6: Add IPv6 basic primitives". Also this patch inlcudes update in Makefile to build NDP. Series-changes: 3 - Added structures and functions descriptions - Fixed style problems Series-changes: 4 - Fixed structures and functions description style Signed-off-by: Viacheslav Mitrofanov Reviewed-by: Ramon Fried Reviewed-by: Simon Glass --- include/ndisc.h | 102 +++++++++++++++++ net/Makefile | 1 + net/ndisc.c | 289 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 392 insertions(+) create mode 100644 include/ndisc.h create mode 100644 net/ndisc.c diff --git a/include/ndisc.h b/include/ndisc.h new file mode 100644 index 0000000000..f6f8eb6507 --- /dev/null +++ b/include/ndisc.h @@ -0,0 +1,102 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2013 Allied Telesis Labs NZ + * Chris Packham, + * + * Copyright (C) 2022 YADRO + * Viacheslav Mitrofanov + */ + +#ifndef __NDISC_H__ +#define __NDISC_H__ + +#include + +/* struct nd_msg - ICMPv6 Neighbour Discovery message format */ +struct nd_msg { + struct icmp6hdr icmph; + struct in6_addr target; + __u8 opt[0]; +}; + +/* struct echo_msg - ICMPv6 echo request/reply message format */ +struct echo_msg { + struct icmp6hdr icmph; + __u16 id; + __u16 sequence; +}; + +/* Neigbour Discovery option types */ +enum { + __ND_OPT_PREFIX_INFO_END = 0, + ND_OPT_SOURCE_LL_ADDR = 1, + ND_OPT_TARGET_LL_ADDR = 2, + ND_OPT_PREFIX_INFO = 3, + ND_OPT_REDIRECT_HDR = 4, + ND_OPT_MTU = 5, + __ND_OPT_MAX +}; + +/* IPv6 destination address of packet waiting for ND */ +extern struct in6_addr net_nd_sol_packet_ip6; +/* MAC destination address of packet waiting for ND */ +extern uchar *net_nd_packet_mac; +/* pointer to packet waiting to be transmitted after ND is resolved */ +extern uchar *net_nd_tx_packet; +/* size of packet waiting to be transmitted */ +extern int net_nd_tx_packet_size; +/* the timer for ND resolution */ +extern ulong net_nd_timer_start; +/* the number of requests we have sent so far */ +extern int net_nd_try; + +#ifdef CONFIG_IPV6 +/** + * ndisc_init() - Make initial steps for ND state machine. + * Usually move variables into initial state. + */ +void ndisc_init(void); + +/** + * ndisc_receive() - Handle ND packet + * + * @et: pointer to incoming packet + * @ip6: pointer to IPv6 header + * @len: incoming packet length + * Return: 0 if handle successfully, -1 if unsupported/unknown ND packet type + */ +int ndisc_receive(struct ethernet_hdr *et, struct ip6_hdr *ip6, int len); + +/** + * ndisc_request() - Send ND request + */ +void ndisc_request(void); + +/** + * ndisc_init() - Check ND response timeout + * + * Return: 0 if no timeout, -1 otherwise + */ +int ndisc_timeout_check(void); +#else +static inline void ndisc_init(void) +{ +} + +static inline int +ndisc_receive(struct ethernet_hdr *et, struct ip6_hdr *ip6, int len) +{ + return -1; +} + +static inline void ndisc_request(void) +{ +} + +static inline int ndisc_timeout_check(void) +{ + return 0; +} +#endif + +#endif /* __NDISC_H__ */ diff --git a/net/Makefile b/net/Makefile index 00d6f9ddf0..df0ea500fe 100644 --- a/net/Makefile +++ b/net/Makefile @@ -20,6 +20,7 @@ obj-$(CONFIG_DM_MDIO) += mdio-uclass.o obj-$(CONFIG_DM_MDIO_MUX) += mdio-mux-uclass.o obj-$(CONFIG_NET) += eth_common.o obj-$(CONFIG_CMD_LINK_LOCAL) += link_local.o +obj-$(CONFIG_IPV6) += ndisc.o obj-$(CONFIG_NET) += net.o obj-$(CONFIG_IPV6) += net6.o obj-$(CONFIG_CMD_NFS) += nfs.o diff --git a/net/ndisc.c b/net/ndisc.c new file mode 100644 index 0000000000..3c0eeeaea3 --- /dev/null +++ b/net/ndisc.c @@ -0,0 +1,289 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2013 Allied Telesis Labs NZ + * Chris Packham, + * + * Copyright (C) 2022 YADRO + * Viacheslav Mitrofanov + */ + +/* Neighbour Discovery for IPv6 */ + +#include +#include +#include +#include + +/* IPv6 destination address of packet waiting for ND */ +struct in6_addr net_nd_sol_packet_ip6 = ZERO_IPV6_ADDR; +/* IPv6 address we are expecting ND advert from */ +static struct in6_addr net_nd_rep_packet_ip6 = ZERO_IPV6_ADDR; +/* MAC destination address of packet waiting for ND */ +uchar *net_nd_packet_mac; +/* pointer to packet waiting to be transmitted after ND is resolved */ +uchar *net_nd_tx_packet; +static uchar net_nd_packet_buf[PKTSIZE_ALIGN + PKTALIGN]; +/* size of packet waiting to be transmitted */ +int net_nd_tx_packet_size; +/* the timer for ND resolution */ +ulong net_nd_timer_start; +/* the number of requests we have sent so far */ +int net_nd_try; + +#define IP6_NDISC_OPT_SPACE(len) (((len) + 2 + 7) & ~7) + +/** + * ndisc_insert_option() - Insert an option into a neighbor discovery packet + * + * @ndisc: pointer to ND packet + * @type: option type to insert + * @data: option data to insert + * @len: data length + * Return: the number of bytes inserted (which may be >= len) + */ +static int +ndisc_insert_option(struct nd_msg *ndisc, int type, u8 *data, int len) +{ + int space = IP6_NDISC_OPT_SPACE(len); + + ndisc->opt[0] = type; + ndisc->opt[1] = space >> 3; + memcpy(&ndisc->opt[2], data, len); + len += 2; + + /* fill the remainder with 0 */ + if (space - len > 0) + memset(&ndisc->opt[len], '\0', space - len); + + return space; +} + +/** + * ndisc_extract_enetaddr() - Extract the Ethernet address from a ND packet + * + * Note that the link layer address could be anything but the only networking + * media that u-boot supports is Ethernet so we assume we're extracting a 6 + * byte Ethernet MAC address. + * + * @ndisc: pointer to ND packet + * @enetaddr: extracted MAC addr + */ +static void ndisc_extract_enetaddr(struct nd_msg *ndisc, uchar enetaddr[6]) +{ + memcpy(enetaddr, &ndisc->opt[2], 6); +} + +/** + * ndisc_has_option() - Check if the ND packet has the specified option set + * + * @ip6: pointer to IPv6 header + * @type: option type to check + * Return: 1 if ND has that option, 0 therwise + */ +static int ndisc_has_option(struct ip6_hdr *ip6, __u8 type) +{ + struct nd_msg *ndisc = (struct nd_msg *)(((uchar *)ip6) + IP6_HDR_SIZE); + + if (ip6->payload_len <= sizeof(struct icmp6hdr)) + return 0; + + return ndisc->opt[0] == type; +} + +static void ip6_send_ns(struct in6_addr *neigh_addr) +{ + struct in6_addr dst_adr; + unsigned char enetaddr[6]; + struct nd_msg *msg; + __u16 len; + uchar *pkt; + unsigned short csum; + unsigned int pcsum; + + debug("sending neighbor solicitation for %pI6c our address %pI6c\n", + neigh_addr, &net_link_local_ip6); + + /* calculate src, dest IPv6 addr and dest Eth addr */ + ip6_make_snma(&dst_adr, neigh_addr); + ip6_make_mult_ethdstaddr(enetaddr, &dst_adr); + len = sizeof(struct icmp6hdr) + IN6ADDRSZ + + IP6_NDISC_OPT_SPACE(INETHADDRSZ); + + pkt = (uchar *)net_tx_packet; + pkt += net_set_ether(pkt, enetaddr, PROT_IP6); + pkt += ip6_add_hdr(pkt, &net_link_local_ip6, &dst_adr, PROT_ICMPV6, + IPV6_NDISC_HOPLIMIT, len); + + /* ICMPv6 - NS */ + msg = (struct nd_msg *)pkt; + msg->icmph.icmp6_type = IPV6_NDISC_NEIGHBOUR_SOLICITATION; + msg->icmph.icmp6_code = 0; + memset(&msg->icmph.icmp6_cksum, 0, sizeof(__be16)); + memset(&msg->icmph.icmp6_unused, 0, sizeof(__be32)); + + /* Set the target address and llsaddr option */ + net_copy_ip6(&msg->target, neigh_addr); + ndisc_insert_option(msg, ND_OPT_SOURCE_LL_ADDR, net_ethaddr, + INETHADDRSZ); + + /* checksum */ + pcsum = csum_partial((__u8 *)msg, len, 0); + csum = csum_ipv6_magic(&net_link_local_ip6, &dst_adr, + len, PROT_ICMPV6, pcsum); + msg->icmph.icmp6_cksum = csum; + pkt += len; + + /* send it! */ + net_send_packet(net_tx_packet, (pkt - net_tx_packet)); +} + +static void +ip6_send_na(uchar *eth_dst_addr, struct in6_addr *neigh_addr, + struct in6_addr *target) +{ + struct nd_msg *msg; + __u16 len; + uchar *pkt; + unsigned short csum; + + debug("sending neighbor advertisement for %pI6c to %pI6c (%pM)\n", + target, neigh_addr, eth_dst_addr); + + len = sizeof(struct icmp6hdr) + IN6ADDRSZ + + IP6_NDISC_OPT_SPACE(INETHADDRSZ); + + pkt = (uchar *)net_tx_packet; + pkt += net_set_ether(pkt, eth_dst_addr, PROT_IP6); + pkt += ip6_add_hdr(pkt, &net_link_local_ip6, neigh_addr, + PROT_ICMPV6, IPV6_NDISC_HOPLIMIT, len); + + /* ICMPv6 - NA */ + msg = (struct nd_msg *)pkt; + msg->icmph.icmp6_type = IPV6_NDISC_NEIGHBOUR_ADVERTISEMENT; + msg->icmph.icmp6_code = 0; + memset(&msg->icmph.icmp6_cksum, 0, sizeof(__be16)); + memset(&msg->icmph.icmp6_unused, 0, sizeof(__be32)); + msg->icmph.icmp6_dataun.u_nd_advt.solicited = 1; + msg->icmph.icmp6_dataun.u_nd_advt.override = 1; + /* Set the target address and lltargetaddr option */ + net_copy_ip6(&msg->target, target); + ndisc_insert_option(msg, ND_OPT_TARGET_LL_ADDR, net_ethaddr, + INETHADDRSZ); + + /* checksum */ + csum = csum_ipv6_magic(&net_link_local_ip6, + neigh_addr, len, PROT_ICMPV6, + csum_partial((__u8 *)msg, len, 0)); + msg->icmph.icmp6_cksum = csum; + pkt += len; + + /* send it! */ + net_send_packet(net_tx_packet, (pkt - net_tx_packet)); +} + +void ndisc_request(void) +{ + if (!ip6_addr_in_subnet(&net_ip6, &net_nd_sol_packet_ip6, + net_prefix_length)) { + if (ip6_is_unspecified_addr(&net_gateway6)) { + puts("## Warning: gatewayip6 is needed but not set\n"); + net_nd_rep_packet_ip6 = net_nd_sol_packet_ip6; + } else { + net_nd_rep_packet_ip6 = net_gateway6; + } + } else { + net_nd_rep_packet_ip6 = net_nd_sol_packet_ip6; + } + + ip6_send_ns(&net_nd_rep_packet_ip6); +} + +int ndisc_timeout_check(void) +{ + ulong t; + + if (ip6_is_unspecified_addr(&net_nd_sol_packet_ip6)) + return 0; + + t = get_timer(0); + + /* check for NDISC timeout */ + if ((t - net_nd_timer_start) > NDISC_TIMEOUT) { + net_nd_try++; + if (net_nd_try >= NDISC_TIMEOUT_COUNT) { + puts("\nNeighbour discovery retry count exceeded; " + "starting again\n"); + net_nd_try = 0; + net_set_state(NETLOOP_FAIL); + } else { + net_nd_timer_start = t; + ndisc_request(); + } + } + return 1; +} + +void ndisc_init(void) +{ + net_nd_packet_mac = NULL; + net_nd_tx_packet = NULL; + net_nd_sol_packet_ip6 = net_null_addr_ip6; + net_nd_rep_packet_ip6 = net_null_addr_ip6; + net_nd_tx_packet_size = 0; + net_nd_tx_packet = &net_nd_packet_buf[0] + (PKTALIGN - 1); + net_nd_tx_packet -= (ulong)net_nd_tx_packet % PKTALIGN; +} + +int ndisc_receive(struct ethernet_hdr *et, struct ip6_hdr *ip6, int len) +{ + struct icmp6hdr *icmp = + (struct icmp6hdr *)(((uchar *)ip6) + IP6_HDR_SIZE); + struct nd_msg *ndisc = (struct nd_msg *)icmp; + uchar neigh_eth_addr[6]; + + switch (icmp->icmp6_type) { + case IPV6_NDISC_NEIGHBOUR_SOLICITATION: + debug("received neighbor solicitation for %pI6c from %pI6c\n", + &ndisc->target, &ip6->saddr); + if (ip6_is_our_addr(&ndisc->target) && + ndisc_has_option(ip6, ND_OPT_SOURCE_LL_ADDR)) { + ndisc_extract_enetaddr(ndisc, neigh_eth_addr); + ip6_send_na(neigh_eth_addr, &ip6->saddr, + &ndisc->target); + } + break; + + case IPV6_NDISC_NEIGHBOUR_ADVERTISEMENT: + /* are we waiting for a reply ? */ + if (ip6_is_unspecified_addr(&net_nd_sol_packet_ip6)) + break; + + if ((memcmp(&ndisc->target, &net_nd_rep_packet_ip6, + sizeof(struct in6_addr)) == 0) && + ndisc_has_option(ip6, ND_OPT_TARGET_LL_ADDR)) { + ndisc_extract_enetaddr(ndisc, neigh_eth_addr); + + /* save address for later use */ + if (!net_nd_packet_mac) + memcpy(net_nd_packet_mac, neigh_eth_addr, 7); + + /* modify header, and transmit it */ + memcpy(((struct ethernet_hdr *)net_nd_tx_packet)->et_dest, + neigh_eth_addr, 6); + + net_send_packet(net_nd_tx_packet, + net_nd_tx_packet_size); + + /* no ND request pending now */ + net_nd_sol_packet_ip6 = net_null_addr_ip6; + net_nd_tx_packet_size = 0; + net_nd_packet_mac = NULL; + } + break; + default: + debug("Unexpected ICMPv6 type 0x%x\n", icmp->icmp6_type); + return -1; + } + + return 0; +} From patchwork Fri Dec 2 09:18:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1711311 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=XqTowV+M; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNnTY5sTVz23nC for ; Fri, 2 Dec 2022 20:20:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EDB868544B; Fri, 2 Dec 2022 10:19:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="XqTowV+M"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3AB2F85403; Fri, 2 Dec 2022 10:18:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 141A7853C5 for ; Fri, 2 Dec 2022 10:18:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id B2A0C411FF; Fri, 2 Dec 2022 09:18:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1669972730; x=1671787131; bh=B6qg5k+/lIJAvFWUEomac1pr9 jQwSkFMv5DFKI7sl8o=; b=XqTowV+M8/O+W8nCSgvZmJr+qjU1GLOT6+b192HDx 3Sk2J19mnnzWsx4h1eP7JY405w5AmOmYm8y4E2omkV3xAR8+vxB/w1p2OYs+xcgc HLYhwCQ2C+tOGscqVdlpbZ9G/qgS+ALPxfoMVLmsy7j7odMy5J/jfKqHuvC+GCfF 4w= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Nnhh-XQaImvu; Fri, 2 Dec 2022 12:18:50 +0300 (MSK) Received: from T-EXCH-01.corp.yadro.com (T-EXCH-01.corp.yadro.com [172.17.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 54B1C40311; Fri, 2 Dec 2022 12:18:50 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-01.corp.yadro.com (172.17.10.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 2 Dec 2022 12:18:50 +0300 Received: from v.yadro.com (10.178.114.10) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 2 Dec 2022 12:18:49 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , Subject: [PATCH v5 05/19] net: ipv6: Add string_to_ip6 converter Date: Fri, 2 Dec 2022 12:18:02 +0300 Message-ID: <20221202091818.2382748-6-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> References: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.178.114.10] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-Exch-05.corp.yadro.com (172.17.10.109) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean This functions is used as a converter from IPv6 address string notation to struct ip6_addr that is used everywhere in IPv6 implementation. For example it is used to parse and convert IPv6 address from tftpboot command. Conversion algorithm uses two passes, first to verify syntax and locate colons and second pass to read the address. In case of valid IPv6 address it returns 0. Examples of valid strings: 2001:db8::0:1234:1 2001:0db8:0000:0000:0000:0000:1234:0001 ::1 ::ffff:192.168.1.1 Examples of invalid strings 2001:db8::0::0 (:: can only appear once) 2001:db8:192.168.1.1::1 (v4 part can only appear at the end) 192.168.1.1 (we don't implicity map v4) Series-changes: 3 - Added function description - Added length parameter to string_to_ip6() Series-changes: 4 - Fixed function description style Signed-off-by: Viacheslav Mitrofanov Reviewed-by: Ramon Fried Reviewed-by: Simon Glass --- include/net6.h | 4 ++ lib/net_utils.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) diff --git a/include/net6.h b/include/net6.h index 9200eae04e..bae0461b11 100644 --- a/include/net6.h +++ b/include/net6.h @@ -174,6 +174,7 @@ extern u32 net_prefix_length; /* Our prefixlength (0 = unknown) */ extern struct in6_addr net_server_ip6; /* Server IPv6 addr (0 = unknown) */ extern bool use_ip6; +#if IS_ENABLED(CONFIG_IPV6) /** * string_to_ip6() - Convert IPv6 string addr to inner IPV6 addr format * @@ -193,11 +194,14 @@ extern bool use_ip6; * @addr: converted IPv6 addr * Return: 0 if conversion successful, -EINVAL if fail */ +int string_to_ip6(const char *s, size_t len, struct in6_addr *addr); +#else static inline int string_to_ip6(const char *s, size_t len, struct in6_addr *addr) { return -EINVAL; } +#endif /** * ip6_is_unspecified_addr() - Check if IPv6 addr is not set i.e. is zero diff --git a/lib/net_utils.c b/lib/net_utils.c index 72a3b098a7..74e8eef879 100644 --- a/lib/net_utils.c +++ b/lib/net_utils.c @@ -11,6 +11,7 @@ #include #include +#include struct in_addr string_to_ip(const char *s) { @@ -43,6 +44,114 @@ struct in_addr string_to_ip(const char *s) return addr; } +#if IS_ENABLED(CONFIG_IPV6) +int string_to_ip6(const char *str, size_t len, struct in6_addr *addr) +{ + int colon_count = 0; + int found_double_colon = 0; + int xstart = 0; /* first zero (double colon) */ + int section_num = 7; /* num words the double colon represents */ + int i; + const char *s = str; + const char *const e = s + len; + struct in_addr zero_ip = {.s_addr = 0}; + + if (!str) + return -1; + + /* First pass, verify the syntax and locate the double colon */ + while (s < e) { + while (s < e && isxdigit((int)*s)) + s++; + if (*s == '\0') + break; + if (*s != ':') { + if (*s == '.' && section_num >= 2) { + struct in_addr v4; + + while (s != str && *(s - 1) != ':') + --s; + v4 = string_to_ip(s); + if (memcmp(&zero_ip, &v4, + sizeof(struct in_addr) != 0)) { + section_num -= 2; + break; + } + } + /* This could be a valid address */ + break; + } + if (s == str) { + /* The address begins with a colon */ + if (*++s != ':') + /* Must start with a double colon or a number */ + goto out_err; + } else { + s++; + if (found_double_colon) + section_num--; + else + xstart++; + } + + if (*s == ':') { + if (found_double_colon) + /* Two double colons are not allowed */ + goto out_err; + found_double_colon = 1; + section_num -= xstart; + s++; + } + + if (++colon_count == 7) + /* Found all colons */ + break; + ++s; + } + + if (colon_count == 0) + goto out_err; + if (*--s == ':') + section_num++; + + /* Second pass, read the address */ + s = str; + for (i = 0; i < 8; i++) { + int val = 0; + char *end; + + if (found_double_colon && + i >= xstart && i < xstart + section_num) { + addr->s6_addr16[i] = 0; + continue; + } + while (*s == ':') + s++; + + if (i == 6 && isdigit((int)*s)) { + struct in_addr v4 = string_to_ip(s); + + if (memcmp(&zero_ip, &v4, + sizeof(struct in_addr)) != 0) { + /* Ending with :IPv4-address */ + addr->s6_addr32[3] = v4.s_addr; + break; + } + } + + val = simple_strtoul(s, &end, 16); + if (end != e && *end != '\0' && *end != ':') + goto out_err; + addr->s6_addr16[i] = htons(val); + s = end; + } + return 0; + +out_err: + return -1; +} +#endif + void string_to_enetaddr(const char *addr, uint8_t *enetaddr) { char *end; From patchwork Fri Dec 2 09:18:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1711313 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=rfjk+FQm; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNnV153lLz23mf for ; Fri, 2 Dec 2022 20:20:25 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E5F6E8545D; Fri, 2 Dec 2022 10:19:24 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="rfjk+FQm"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 51477853DB; Fri, 2 Dec 2022 10:19:00 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B91B285338 for ; Fri, 2 Dec 2022 10:18:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 68E3B4088A; Fri, 2 Dec 2022 09:18:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1669972731; x=1671787132; bh=TZzmJ7hrqgR4GS7wxZFYVr/Zd il5wkxfxpvqYsrF/Ko=; b=rfjk+FQmxUWEJINb9v45qUHMbcTnmaNdoe5MN7Zi2 T8keJQ8b92zYvT/e+EbIYvgTXda3d9wfsm1UBkxNfn8Ll9DH/PUkcl61QClh3UdF ux8+qj0bsKxueQt3bDE/zibEHSeHe86Xxxcg0zqhJGNB8d22+A2FSyIylrmnBOES Cw= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6Z-VjH2kQEnw; Fri, 2 Dec 2022 12:18:51 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (T-EXCH-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 4E8374014D; Fri, 2 Dec 2022 12:18:51 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 2 Dec 2022 12:18:51 +0300 Received: from v.yadro.com (10.178.114.10) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 2 Dec 2022 12:18:50 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , Subject: [PATCH v5 06/19] net: ipv6: Enable IPv6 typeconversion specifier Date: Fri, 2 Dec 2022 12:18:03 +0300 Message-ID: <20221202091818.2382748-7-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> References: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.178.114.10] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-Exch-05.corp.yadro.com (172.17.10.109) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Add the possibility to recognize IPv6 address in print function. To output IPv6 address use %pI6 specifier. Series-changes: 3 - Substituted #if (...) for if (...) to get better readability Signed-off-by: Viacheslav Mitrofanov Reviewed-by: Ramon Fried Reviewed-by: Simon Glass --- lib/vsprintf.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index fe06aa2d71..530d8088c7 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -450,10 +450,6 @@ static char *uuid_string(char *buf, char *end, u8 *addr, int field_width, * decimal for v4 and colon separated network-order 16 bit hex for v6) * - 'i' [46] for 'raw' IPv4/IPv6 addresses, IPv6 omits the colons, IPv4 is * currently the same - * - * Note: IPv6 support is currently if(0)'ed out. If you ever need - * %pI6, please add an IPV6 Kconfig knob, make your code select or - * depend on that, and change the 0 below to CONFIG_IS_ENABLED(IPV6). */ static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field_width, int precision, int flags) @@ -498,8 +494,7 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr, flags |= SPECIAL; /* Fallthrough */ case 'I': - /* %pI6 currently unused */ - if (0 && fmt[1] == '6') + if (IS_ENABLED(CONFIG_IPV6) && fmt[1] == '6') return ip6_addr_string(buf, end, ptr, field_width, precision, flags); if (fmt[1] == '4') From patchwork Fri Dec 2 09:18:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1711312 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=iCRC1Mv/; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNnTp0fjmz23nC for ; Fri, 2 Dec 2022 20:20:13 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A5F6685452; Fri, 2 Dec 2022 10:19:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="iCRC1Mv/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8153F85424; Fri, 2 Dec 2022 10:19:03 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CE6C98533A for ; Fri, 2 Dec 2022 10:18:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 7CC9741200; Fri, 2 Dec 2022 09:18:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1669972732; x=1671787133; bh=+BfDIPOhHeHGL4DrdlH9beiYs G67UgDLK52olISQ10k=; b=iCRC1Mv/hb2u26TamzoY0cDL+ESVEl7iBMSgzvCRS Ub1PUSEba6LTXqjox/N1iC9UprCtSwCPU3BmWINPFbSpgJibgIhN4Joimy4cZ8d6 nLDeLauMBewiggobiJYwSutiasIKEVGftdueThWkOcnPtN2F6UotMIGrtzTtDf9E cM= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LDH1qLcoHIP3; Fri, 2 Dec 2022 12:18:52 +0300 (MSK) Received: from T-EXCH-01.corp.yadro.com (T-EXCH-01.corp.yadro.com [172.17.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 5EB6640311; Fri, 2 Dec 2022 12:18:52 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-01.corp.yadro.com (172.17.10.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 2 Dec 2022 12:18:52 +0300 Received: from v.yadro.com (10.178.114.10) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 2 Dec 2022 12:18:51 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , Subject: [PATCH v5 07/19] net: ipv6: Add ip6addr, gatewayip6, serverip6 variables callbacks Date: Fri, 2 Dec 2022 12:18:04 +0300 Message-ID: <20221202091818.2382748-8-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> References: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.178.114.10] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-Exch-05.corp.yadro.com (172.17.10.109) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Implement actions on ip6addr, gatewayip6, serverip6 varaibles. on_ip6addr - convert IPv6 string addr to struct ip6_addr on_gatewayip6 - convert IPv6 string addr to struct ip6_addr on_serverip6 - convert IPv6 string addr to struct ip6_addr Series-changes: 3 - Removed memory allocation - Substituted -1 for error code Signed-off-by: Viacheslav Mitrofanov Reviewed-by: Ramon Fried Reviewed-by: Simon Glass --- net/net6.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/net/net6.c b/net/net6.c index 7cd442e6e2..cfbd4f5827 100644 --- a/net/net6.c +++ b/net/net6.c @@ -29,3 +29,51 @@ struct in6_addr net_server_ip6 = ZERO_IPV6_ADDR; u32 net_prefix_length; bool use_ip6; + +static int on_ip6addr(const char *name, const char *value, enum env_op op, + int flags) +{ + char *mask; + size_t len; + + if (flags & H_PROGRAMMATIC) + return 0; + + if (op == env_op_delete) { + net_prefix_length = 0; + net_copy_ip6(&net_ip6, &net_null_addr_ip6); + return 0; + } + + mask = strchr(value, '/'); + len = strlen(value); + + if (mask) + net_prefix_length = simple_strtoul(value + len, NULL, 10); + + return string_to_ip6(value, len, &net_ip6); +} + +U_BOOT_ENV_CALLBACK(ip6addr, on_ip6addr); + +static int on_gatewayip6(const char *name, const char *value, enum env_op op, + int flags) +{ + if (flags & H_PROGRAMMATIC) + return 0; + + return string_to_ip6(value, strlen(value), &net_gateway6); +} + +U_BOOT_ENV_CALLBACK(gatewayip6, on_gatewayip6); + +static int on_serverip6(const char *name, const char *value, enum env_op op, + int flags) +{ + if (flags & H_PROGRAMMATIC) + return 0; + + return string_to_ip6(value, strlen(value), &net_server_ip6); +} + +U_BOOT_ENV_CALLBACK(serverip6, on_serverip6); From patchwork Fri Dec 2 09:18:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1711317 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=GyD2j9xW; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNnVh5WqLz23nB for ; Fri, 2 Dec 2022 20:21:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 29C6D85409; Fri, 2 Dec 2022 10:19:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="GyD2j9xW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 86980853D1; Fri, 2 Dec 2022 10:19:16 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0B6D0853D0 for ; Fri, 2 Dec 2022 10:18:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id A96044088A; Fri, 2 Dec 2022 09:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1669972733; x=1671787134; bh=FvdB5VHL9vLji72q9MOxN6x5S WJNTdX8S/C+VJx8hwI=; b=GyD2j9xWt2+TR2OI+byxK5ThDpb+6Fh07K1miSP+W PzA9M+sfXhR6WWUyGipDRqvfVa2VDlha6MBWXKvgwsq7ugsjHtVsjHLo5G/2Ycod IxisIi2s8wpvaV8woQRRtqugw92XnhEpHd9geMjZItw3qPt1cX0BktWLCikfrS5u gU= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WtpnxbO_bbqZ; Fri, 2 Dec 2022 12:18:53 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (T-EXCH-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 703014014D; Fri, 2 Dec 2022 12:18:53 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 2 Dec 2022 12:18:53 +0300 Received: from v.yadro.com (10.178.114.10) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 2 Dec 2022 12:18:52 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , Subject: [PATCH v5 08/19] net: ipv6: Add implementation of main IPv6 functions Date: Fri, 2 Dec 2022 12:18:05 +0300 Message-ID: <20221202091818.2382748-9-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> References: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.178.114.10] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-Exch-05.corp.yadro.com (172.17.10.109) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Functions that were exposed in "net: ipv6: Add IPv6 basic primitives" had only empty implementations and were exposed as API for futher patches. This patch add implementation of these functions. Main functions are: net_ip6_handler() - IPv6 packet handler for incoming packets; net_send_udp_packet6() - make up and send an UDP packet; csum_ipv6_magic() - compute checksum of IPv6 "psuedo-header" per RFC2460 section 8.1; ip6_addr_in_subnet() - check if an address is in our subnet. Other functions are auxiliary. Series-changes: 3 - Added comments - Fixed style problems - Fixed return codes instead of -1 Signed-off-by: Viacheslav Mitrofanov Reviewed-by: Ramon Fried Reviewed-by: Simon Glass --- include/net6.h | 161 +++++++++++++--------- net/net6.c | 362 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 459 insertions(+), 64 deletions(-) diff --git a/include/net6.h b/include/net6.h index bae0461b11..972eb42034 100644 --- a/include/net6.h +++ b/include/net6.h @@ -195,13 +195,6 @@ extern bool use_ip6; * Return: 0 if conversion successful, -EINVAL if fail */ int string_to_ip6(const char *s, size_t len, struct in6_addr *addr); -#else -static inline int -string_to_ip6(const char *s, size_t len, struct in6_addr *addr) -{ - return -EINVAL; -} -#endif /** * ip6_is_unspecified_addr() - Check if IPv6 addr is not set i.e. is zero @@ -209,10 +202,7 @@ string_to_ip6(const char *s, size_t len, struct in6_addr *addr) * @addr: IPv6 addr * Return: 0 if addr is not set, -1 if is set */ -static inline int ip6_is_unspecified_addr(struct in6_addr *addr) -{ - return -1; -} +int ip6_is_unspecified_addr(struct in6_addr *addr); /** * ip6_is_our_addr() - Check if IPv6 addr belongs to our host addr @@ -224,10 +214,7 @@ static inline int ip6_is_unspecified_addr(struct in6_addr *addr) * @addr: addr to check * Return: 0 if addr is our, -1 otherwise */ -static inline int ip6_is_our_addr(struct in6_addr *addr) -{ - return -1; -} +int ip6_is_our_addr(struct in6_addr *addr); /** * ip6_addr_in_subnet() - Check if two IPv6 addresses are in the same subnet @@ -237,12 +224,8 @@ static inline int ip6_is_our_addr(struct in6_addr *addr) * @prefix_length: network mask length * Return: 0 if two addresses in the same subnet, -1 otherwise */ -static inline int -ip6_addr_in_subnet(struct in6_addr *our_addr, struct in6_addr *neigh_addr, - u32 prefix_length) -{ - return -1; -} +int ip6_addr_in_subnet(struct in6_addr *our_addr, struct in6_addr *neigh_addr, + u32 prefix_length); /** * ip6_make_lladd() - rMake up IPv6 Link Local address @@ -250,10 +233,7 @@ ip6_addr_in_subnet(struct in6_addr *our_addr, struct in6_addr *neigh_addr, * @lladdr: formed IPv6 Link Local address * @enetaddr: MAC addr of a device */ -static inline void -ip6_make_lladdr(struct in6_addr *lladdr, unsigned char const enetaddr[6]) -{ -} +void ip6_make_lladdr(struct in6_addr *lladr, unsigned char const enetaddr[6]); /** * ip6_make_snma() - aMake up Solicited Node Multicast Address from IPv6 addr @@ -261,10 +241,7 @@ ip6_make_lladdr(struct in6_addr *lladdr, unsigned char const enetaddr[6]) * @mcast_addr: formed SNMA addr * @ip6_addr: base IPv6 addr */ -static inline void -ip6_make_snma(struct in6_addr *mcast_addr, struct in6_addr *ip6_addr) -{ -} +void ip6_make_snma(struct in6_addr *mcast_addr, struct in6_addr *ip6_addr); /** * ip6_make_mult_ethdstaddr() - Make up IPv6 multicast addr @@ -272,11 +249,8 @@ ip6_make_snma(struct in6_addr *mcast_addr, struct in6_addr *ip6_addr) * @enetaddr: MAC addr of a device * @mcast_addr: formed IPv6 multicast addr */ -static inline void -ip6_make_mult_ethdstaddr(unsigned char enetaddr[6], - struct in6_addr *mcast_addr) -{ -} +void ip6_make_mult_ethdstaddr(unsigned char enetaddr[6], + struct in6_addr *mcast_addr); /** * csum_partial() - Compute an internet checksum @@ -286,11 +260,7 @@ ip6_make_mult_ethdstaddr(unsigned char enetaddr[6], * @sum: initial sum to be added in * Return: internet checksum of the buffer */ -static inline unsigned int -csum_partial(const unsigned char *buff, int len, unsigned int sum) -{ - return 0; -} +unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum); /** * csum_ipv6_magic() - Compute checksum of IPv6 "psuedo-header" per RFC2460 section 8.1 @@ -302,13 +272,9 @@ csum_partial(const unsigned char *buff, int len, unsigned int sum) * @csum: upper layer checksum * Return: computed checksum */ -static inline unsigned short -csum_ipv6_magic(struct in6_addr *saddr, - struct in6_addr *daddr, u16 len, - unsigned short proto, unsigned int csum) -{ - return 0; -} +unsigned short int csum_ipv6_magic(struct in6_addr *saddr, + struct in6_addr *daddr, u16 len, + unsigned short proto, unsigned int csum); /** * ip6_add_hdr() - Make up IPv6 header @@ -321,12 +287,8 @@ csum_ipv6_magic(struct in6_addr *saddr, * @payload_len: payload length * Return: IPv6 header length */ -static inline unsigned int -ip6_add_hdr(uchar *xip, struct in6_addr *src, struct in6_addr *dest, - int nextheader, int hoplimit, int payload_len) -{ - return 0; -} +int ip6_add_hdr(uchar *xip, struct in6_addr *src, struct in6_addr *dest, + int nextheader, int hoplimit, int payload_len); /** * net_send_udp_packet6() - Make up UDP packet and send it @@ -338,12 +300,8 @@ ip6_add_hdr(uchar *xip, struct in6_addr *src, struct in6_addr *dest, * @len: UDP packet length * Return: 0 if send successfully, -1 otherwise */ -static inline int -net_send_udp_packet6(uchar *ether, struct in6_addr *dest, - int dport, int sport, int len) -{ - return -1; -} +int net_send_udp_packet6(uchar *ether, struct in6_addr *dest, int dport, + int sport, int len); /** * net_ip6_handler() - Handle IPv6 packet @@ -353,12 +311,7 @@ net_send_udp_packet6(uchar *ether, struct in6_addr *dest, * @len: incoming packet len * Return: 0 if handle packet successfully, -EINVAL in case of invalid protocol */ -static inline int -net_ip6_handler(struct ethernet_hdr *et, struct ip6_hdr *ip6, - int len) -{ - return -EINVAL; -} +int net_ip6_handler(struct ethernet_hdr *et, struct ip6_hdr *ip6, int len); /** * net_copy_ip6() - Copy IPv6 addr @@ -368,6 +321,86 @@ net_ip6_handler(struct ethernet_hdr *et, struct ip6_hdr *ip6, */ static inline void net_copy_ip6(void *to, const void *from) { + memcpy((void *)to, from, sizeof(struct in6_addr)); } +#else +static inline int +string_to_ip6(const char *s, size_t len, struct in6_addr *addr) +{ + return -EINVAL; +} + +static inline int ip6_is_unspecified_addr(struct in6_addr *addr) +{ + return -1; +} + +static inline int ip6_is_our_addr(struct in6_addr *addr) +{ + return -1; +} + +static inline int +ip6_addr_in_subnet(struct in6_addr *our_addr, struct in6_addr *neigh_addr, + u32 prefix_length) +{ + return -1; +} + +static inline void +ip6_make_lladdr(struct in6_addr *lladdr, unsigned char const enetaddr[6]) +{ +} + +static inline void +ip6_make_snma(struct in6_addr *mcast_addr, struct in6_addr *ip6_addr) +{ +} + +static inline void +ip6_make_mult_ethdstaddr(unsigned char enetaddr[6], + struct in6_addr *mcast_addr) +{ +} + +static inline unsigned int +csum_partial(const unsigned char *buff, int len, unsigned int sum) +{ + return 0; +} + +static inline unsigned short +csum_ipv6_magic(struct in6_addr *saddr, + struct in6_addr *daddr, u16 len, + unsigned short proto, unsigned int csum) +{ + return 0; +} + +static inline unsigned int +ip6_add_hdr(uchar *xip, struct in6_addr *src, struct in6_addr *dest, + int nextheader, int hoplimit, int payload_len) +{ + return 0; +} + +static inline int +net_send_udp_packet6(uchar *ether, struct in6_addr *dest, + int dport, int sport, int len) +{ + return -1; +} + +static inline int +net_ip6_handler(struct ethernet_hdr *et, struct ip6_hdr *ip6, + int len) +{ + return -EINVAL; +} + +static inline void net_copy_ip6(void *to, const void *from) +{ +} +#endif #endif /* __NET6_H__ */ diff --git a/net/net6.c b/net/net6.c index cfbd4f5827..e604227fe5 100644 --- a/net/net6.c +++ b/net/net6.c @@ -14,6 +14,7 @@ #include #include #include +#include /* NULL IPv6 address */ struct in6_addr const net_null_addr_ip6 = ZERO_IPV6_ADDR; @@ -77,3 +78,364 @@ static int on_serverip6(const char *name, const char *value, enum env_op op, } U_BOOT_ENV_CALLBACK(serverip6, on_serverip6); + +int ip6_is_unspecified_addr(struct in6_addr *addr) +{ + return !(addr->s6_addr32[0] | addr->s6_addr32[1] | + addr->s6_addr32[2] | addr->s6_addr32[3]); +} + +int ip6_is_our_addr(struct in6_addr *addr) +{ + return !memcmp(addr, &net_link_local_ip6, sizeof(struct in6_addr)) || + !memcmp(addr, &net_ip6, sizeof(struct in6_addr)); +} + +void ip6_make_eui(unsigned char eui[8], unsigned char const enetaddr[6]) +{ + memcpy(eui, enetaddr, 3); + memcpy(&eui[5], &enetaddr[3], 3); + eui[3] = 0xff; + eui[4] = 0xfe; + eui[0] ^= 2; /* "u" bit set to indicate global scope */ +} + +void ip6_make_lladdr(struct in6_addr *lladr, unsigned char const enetaddr[6]) +{ + unsigned char eui[8]; + + memset(lladr, 0, sizeof(struct in6_addr)); + lladr->s6_addr16[0] = htons(IPV6_LINK_LOCAL_PREFIX); + ip6_make_eui(eui, enetaddr); + memcpy(&lladr->s6_addr[8], eui, 8); +} + +void ip6_make_snma(struct in6_addr *mcast_addr, struct in6_addr *ip6_addr) +{ + memset(mcast_addr, 0, sizeof(struct in6_addr)); + mcast_addr->s6_addr[0] = 0xff; + mcast_addr->s6_addr[1] = IPV6_ADDRSCOPE_LINK; + mcast_addr->s6_addr[11] = 0x01; + mcast_addr->s6_addr[12] = 0xff; + mcast_addr->s6_addr[13] = ip6_addr->s6_addr[13]; + mcast_addr->s6_addr[14] = ip6_addr->s6_addr[14]; + mcast_addr->s6_addr[15] = ip6_addr->s6_addr[15]; +} + +void +ip6_make_mult_ethdstaddr(unsigned char enetaddr[6], struct in6_addr *mcast_addr) +{ + enetaddr[0] = 0x33; + enetaddr[1] = 0x33; + memcpy(&enetaddr[2], &mcast_addr->s6_addr[12], 4); +} + +int +ip6_addr_in_subnet(struct in6_addr *our_addr, struct in6_addr *neigh_addr, + u32 plen) +{ + __be32 *addr_dwords; + __be32 *neigh_dwords; + + addr_dwords = our_addr->s6_addr32; + neigh_dwords = neigh_addr->s6_addr32; + + while (plen > 32) { + if (*addr_dwords++ != *neigh_dwords++) + return 0; + + plen -= 32; + } + + /* Check any remaining bits */ + if (plen > 0) { + if ((*addr_dwords >> (32 - plen)) != + (*neigh_dwords >> (32 - plen))) { + return 0; + } + } + + return 1; +} + +static inline unsigned int csum_fold(unsigned int sum) +{ + sum = (sum & 0xffff) + (sum >> 16); + sum = (sum & 0xffff) + (sum >> 16); + + /* Opaque moment. If reverse it to zero it will not be checked on + * receiver's side. It leads to bad negibour advertisement. + */ + if (sum == 0xffff) + return sum; + + return ~sum; +} + +static inline unsigned short from32to16(unsigned int x) +{ + /* add up 16-bit and 16-bit for 16+c bit */ + x = (x & 0xffff) + (x >> 16); + /* add up carry.. */ + x = (x & 0xffff) + (x >> 16); + return x; +} + +static u32 csum_do_csum(const u8 *buff, int len) +{ + int odd; + unsigned int result = 0; + + if (len <= 0) + goto out; + odd = 1 & (unsigned long)buff; + if (odd) { +#ifdef __LITTLE_ENDIAN + result += (*buff << 8); +#else + result = *buff; +#endif + len--; + buff++; + } + if (len >= 2) { + if (2 & (unsigned long)buff) { + result += *(unsigned short *)buff; + len -= 2; + buff += 2; + } + if (len >= 4) { + const unsigned char *end = buff + ((u32)len & ~3); + unsigned int carry = 0; + + do { + unsigned int w = *(unsigned int *)buff; + + buff += 4; + result += carry; + result += w; + carry = (w > result); + } while (buff < end); + result += carry; + result = (result & 0xffff) + (result >> 16); + } + if (len & 2) { + result += *(unsigned short *)buff; + buff += 2; + } + } + if (len & 1) +#ifdef __LITTLE_ENDIAN + result += *buff; +#else + result += (*buff << 8); +#endif + result = from32to16(result); + if (odd) + result = ((result >> 8) & 0xff) | ((result & 0xff) << 8); +out: + return result; +} + +unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum) +{ + unsigned int result = csum_do_csum(buff, len); + + /* add in old sum, and carry.. */ + result += sum; + /* 16+c bits -> 16 bits */ + result = (result & 0xffff) + (result >> 16); + return result; +} + +unsigned short int +csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr, u16 len, + unsigned short proto, unsigned int csum) +{ + int carry; + u32 ulen; + u32 uproto; + u32 sum = csum; + + sum += saddr->s6_addr32[0]; + carry = (sum < saddr->s6_addr32[0]); + sum += carry; + + sum += saddr->s6_addr32[1]; + carry = (sum < saddr->s6_addr32[1]); + sum += carry; + + sum += saddr->s6_addr32[2]; + carry = (sum < saddr->s6_addr32[2]); + sum += carry; + + sum += saddr->s6_addr32[3]; + carry = (sum < saddr->s6_addr32[3]); + sum += carry; + + sum += daddr->s6_addr32[0]; + carry = (sum < daddr->s6_addr32[0]); + sum += carry; + + sum += daddr->s6_addr32[1]; + carry = (sum < daddr->s6_addr32[1]); + sum += carry; + + sum += daddr->s6_addr32[2]; + carry = (sum < daddr->s6_addr32[2]); + sum += carry; + + sum += daddr->s6_addr32[3]; + carry = (sum < daddr->s6_addr32[3]); + sum += carry; + + ulen = htonl((u32)len); + sum += ulen; + carry = (sum < ulen); + sum += carry; + + uproto = htonl(proto); + sum += uproto; + carry = (sum < uproto); + sum += carry; + + return csum_fold(sum); +} + +int ip6_add_hdr(uchar *xip, struct in6_addr *src, struct in6_addr *dest, + int nextheader, int hoplimit, int payload_len) +{ + struct ip6_hdr *ip6 = (struct ip6_hdr *)xip; + + ip6->version = 6; + ip6->priority = 0; + ip6->flow_lbl[0] = 0; + ip6->flow_lbl[1] = 0; + ip6->flow_lbl[2] = 0; + ip6->payload_len = htons(payload_len); + ip6->nexthdr = nextheader; + ip6->hop_limit = hoplimit; + net_copy_ip6(&ip6->saddr, src); + net_copy_ip6(&ip6->daddr, dest); + + return sizeof(struct ip6_hdr); +} + +int net_send_udp_packet6(uchar *ether, struct in6_addr *dest, int dport, + int sport, int len) +{ + uchar *pkt; + struct udp_hdr *udp; + u16 csum_p; + + udp = (struct udp_hdr *)((uchar *)net_tx_packet + net_eth_hdr_size() + + IP6_HDR_SIZE); + + udp->udp_dst = htons(dport); + udp->udp_src = htons(sport); + udp->udp_len = htons(len + UDP_HDR_SIZE); + + /* checksum */ + udp->udp_xsum = 0; + csum_p = csum_partial((u8 *)udp, len + UDP_HDR_SIZE, 0); + udp->udp_xsum = csum_ipv6_magic(&net_ip6, dest, len + UDP_HDR_SIZE, + IPPROTO_UDP, csum_p); + + /* if MAC address was not discovered yet, save the packet and do + * neighbour discovery + */ + if (!memcmp(ether, net_null_ethaddr, 6)) { + net_copy_ip6(&net_nd_sol_packet_ip6, dest); + net_nd_packet_mac = ether; + + pkt = net_nd_tx_packet; + pkt += net_set_ether(pkt, net_nd_packet_mac, PROT_IP6); + pkt += ip6_add_hdr(pkt, &net_ip6, dest, IPPROTO_UDP, 64, + len + UDP_HDR_SIZE); + memcpy(pkt, (uchar *)udp, len + UDP_HDR_SIZE); + + /* size of the waiting packet */ + net_nd_tx_packet_size = (pkt - net_nd_tx_packet) + + UDP_HDR_SIZE + len; + + /* and do the neighbor solicitation */ + net_nd_try = 1; + net_nd_timer_start = get_timer(0); + ndisc_request(); + return 1; /* waiting */ + } + + pkt = (uchar *)net_tx_packet; + pkt += net_set_ether(pkt, ether, PROT_IP6); + pkt += ip6_add_hdr(pkt, &net_ip6, dest, IPPROTO_UDP, 64, + len + UDP_HDR_SIZE); + (void)eth_send(net_tx_packet, pkt - net_tx_packet + UDP_HDR_SIZE + len); + + return 0; /* transmitted */ +} + +int net_ip6_handler(struct ethernet_hdr *et, struct ip6_hdr *ip6, int len) +{ + struct in_addr zero_ip = {.s_addr = 0 }; + struct icmp6hdr *icmp; + struct udp_hdr *udp; + u16 csum; + u16 csum_p; + u16 hlen; + + if (len < IP6_HDR_SIZE) + return -EINVAL; + + if (ip6->version != 6) + return -EINVAL; + + switch (ip6->nexthdr) { + case PROT_ICMPV6: + icmp = (struct icmp6hdr *)(((uchar *)ip6) + IP6_HDR_SIZE); + csum = icmp->icmp6_cksum; + hlen = ntohs(ip6->payload_len); + icmp->icmp6_cksum = 0; + /* checksum */ + csum_p = csum_partial((u8 *)icmp, hlen, 0); + icmp->icmp6_cksum = csum_ipv6_magic(&ip6->saddr, &ip6->daddr, + hlen, PROT_ICMPV6, csum_p); + + if (icmp->icmp6_cksum != csum) + return -EINVAL; + + switch (icmp->icmp6_type) { + case IPV6_NDISC_NEIGHBOUR_SOLICITATION: + case IPV6_NDISC_NEIGHBOUR_ADVERTISEMENT: + ndisc_receive(et, ip6, len); + break; + default: + break; + } + break; + case IPPROTO_UDP: + udp = (struct udp_hdr *)(((uchar *)ip6) + IP6_HDR_SIZE); + csum = udp->udp_xsum; + hlen = ntohs(ip6->payload_len); + udp->udp_xsum = 0; + /* checksum */ + csum_p = csum_partial((u8 *)udp, hlen, 0); + udp->udp_xsum = csum_ipv6_magic(&ip6->saddr, &ip6->daddr, + hlen, IPPROTO_UDP, csum_p); + + if (csum != udp->udp_xsum) + return -EINVAL; + + /* IP header OK. Pass the packet to the current handler. */ + net_get_udp_handler()((uchar *)ip6 + IP6_HDR_SIZE + + UDP_HDR_SIZE, + ntohs(udp->udp_dst), + zero_ip, + ntohs(udp->udp_src), + ntohs(udp->udp_len) - 8); + break; + default: + return -EINVAL; + } + + return 0; +} From patchwork Fri Dec 2 09:18:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1711314 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=Qd0LWb1T; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNnVF29g4z23nB for ; Fri, 2 Dec 2022 20:20:37 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6CB6485461; Fri, 2 Dec 2022 10:19:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="Qd0LWb1T"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E57D885441; Fri, 2 Dec 2022 10:19:09 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 38F4F853DC for ; Fri, 2 Dec 2022 10:18:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id AB935411FF; Fri, 2 Dec 2022 09:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1669972734; x=1671787135; bh=OI33Hxmsk+p7dN3xfVUGxPqha AbUd2x/UACNt770gdI=; b=Qd0LWb1TaVxzON32KiS1IH7MueafAgSqmPJ0K/h7Y H6DApwM6BGSGDC10Tkapxwmwaj6ljhkGHm2GaHHmS0jwYMI2vRSUKQLn82ARq8hP 1p8m2qe+3lVcITcERigTP9duCd0U9XrjkUqIFN7521/RFFoCaoa1l9gtsCcXKuYN yU= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XcMfb4qgPxa8; Fri, 2 Dec 2022 12:18:54 +0300 (MSK) Received: from T-EXCH-01.corp.yadro.com (T-EXCH-01.corp.yadro.com [172.17.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 8A0EE40311; Fri, 2 Dec 2022 12:18:54 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-01.corp.yadro.com (172.17.10.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 2 Dec 2022 12:18:54 +0300 Received: from v.yadro.com (10.178.114.10) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 2 Dec 2022 12:18:53 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , Subject: [PATCH v5 09/19] net: ipv6: Incorporate IPv6 support into u-boot net subsystem Date: Fri, 2 Dec 2022 12:18:06 +0300 Message-ID: <20221202091818.2382748-10-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> References: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.178.114.10] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-Exch-05.corp.yadro.com (172.17.10.109) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Add net_ip6_handler (an IPv6 packet handler) into net_loop. Add neighbor discovery mechanism into network init process. That is the main step to run IPv6 in u-boot. Now u-boot is capable to use NDP and handle IPv6 packets. Signed-off-by: Viacheslav Mitrofanov Reviewed-by: Ramon Fried Reviewed-by: Simon Glass --- net/net.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/net/net.c b/net/net.c index aca20e43b0..63bf962b53 100644 --- a/net/net.c +++ b/net/net.c @@ -91,6 +91,8 @@ #include #include #include +#include +#include #include #include #include @@ -343,8 +345,17 @@ void net_auto_load(void) static int net_init_loop(void) { - if (eth_get_dev()) + if (eth_get_dev()) { memcpy(net_ethaddr, eth_get_ethaddr(), 6); + + 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)); + } + } else /* * Not ideal, but there's no way to get the actual error, and I @@ -385,6 +396,7 @@ int net_init(void) (i + 1) * PKTSIZE_ALIGN; } arp_init(); + ndisc_init(); net_clear_handlers(); /* Only need to setup buffer pointers once. */ @@ -589,6 +601,11 @@ restart: if (arp_timeout_check() > 0) time_start = get_timer(0); + if (IS_ENABLED(CONFIG_IPV6)) { + if (use_ip6 && (ndisc_timeout_check() > 0)) + time_start = get_timer(0); + } + /* * Check the ethernet for a new packet. The ethernet * receive routine will process it. @@ -1243,6 +1260,10 @@ void net_process_received_packet(uchar *in_packet, int len) case PROT_RARP: rarp_receive(ip, len); break; +#endif +#if IS_ENABLED(CONFIG_IPV6) + case PROT_IP6: + net_ip6_handler(et, (struct ip6_hdr *)ip, len); #endif case PROT_IP: debug_cond(DEBUG_NET_PKT, "Got IP\n"); From patchwork Fri Dec 2 09:18:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1711316 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=XDsUa9hn; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNnVT28c1z23nC for ; Fri, 2 Dec 2022 20:20:49 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1B6808545A; Fri, 2 Dec 2022 10:19:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="XDsUa9hn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9431A853D1; Fri, 2 Dec 2022 10:19:12 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 879D985221 for ; Fri, 2 Dec 2022 10:18:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 32A394014D; Fri, 2 Dec 2022 09:18:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1669972735; x=1671787136; bh=EfPY34axddgOvqPxeOdHspO4+ ZPIVGXH9KGbuVsBihs=; b=XDsUa9hn6402EPXHN59Q4E3LHhQyy8gWaFiIGchng FFglRvSPXpGv/wvdecjBkV/UxZbziuKo9PMIYVJcrlvWvPiX73o80Ph06W5ws7+8 oESS2LmV3TqLjPonKTAXKagHc+6MYsfZhLkLttebuu0gTy9syBP3b2jBLM/MqqAQ O8= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YJ53d2XK0Jji; Fri, 2 Dec 2022 12:18:55 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (T-EXCH-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 9AFC140889; Fri, 2 Dec 2022 12:18:55 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 2 Dec 2022 12:18:55 +0300 Received: from v.yadro.com (10.178.114.10) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 2 Dec 2022 12:18:54 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , Subject: [PATCH v5 10/19] net: tftp: Add IPv6 support for tftpboot Date: Fri, 2 Dec 2022 12:18:07 +0300 Message-ID: <20221202091818.2382748-11-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> References: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.178.114.10] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-Exch-05.corp.yadro.com (172.17.10.109) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean The command tftpboot uses IPv4 by default. Add the possibility to use IPv6 instead. If an address in the command is an IPv6 address it will use IPv6 to boot or if there is a suffix -ipv6 in the end of the command it also force using IPv6. All other tftpboot features and parameters are left the same. Signed-off-by: Viacheslav Mitrofanov Reviewed-by: Ramon Fried Reviewed-by: Simon Glass --- cmd/net.c | 35 ++++++++++++++++++++++++++++++++ net/net.c | 17 ++++++++++++++-- net/tftp.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 103 insertions(+), 7 deletions(-) diff --git a/cmd/net.c b/cmd/net.c index f6d9f5ea3a..221b3525ca 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -45,12 +46,22 @@ int do_tftpb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return ret; } +#if IS_ENABLED(CONFIG_IPV6) +U_BOOT_CMD( + tftpboot, 4, 1, do_tftpb, + "boot image via network using TFTP protocol\n" + "To use IPv6 add -ipv6 parameter or use IPv6 hostIPaddr framed " + "with [] brackets", + "[loadAddress] [[hostIPaddr:]bootfilename] [" USE_IP6_CMD_PARAM "]" +); +#else U_BOOT_CMD( tftpboot, 3, 1, do_tftpb, "load file via network using TFTP protocol", "[loadAddress] [[hostIPaddr:]bootfilename]" ); #endif +#endif #ifdef CONFIG_CMD_TFTPPUT static int do_tftpput(struct cmd_tbl *cmdtp, int flag, int argc, @@ -306,6 +317,17 @@ static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc, if (s != NULL) image_load_addr = hextoul(s, NULL); + if (IS_ENABLED(CONFIG_IPV6)) { + use_ip6 = false; + + /* IPv6 parameter has to be always *last* */ + if (!strcmp(argv[argc - 1], USE_IP6_CMD_PARAM)) { + use_ip6 = true; + /* It is a hack not to break switch/case code */ + --argc; + } + } + if (parse_args(proto, argc, argv)) { bootstage_error(BOOTSTAGE_ID_NET_START); return CMD_RET_USAGE; @@ -313,6 +335,19 @@ static int netboot_common(enum proto_t proto, struct cmd_tbl *cmdtp, int argc, bootstage_mark(BOOTSTAGE_ID_NET_START); + if (IS_ENABLED(CONFIG_IPV6) && !use_ip6) { + char *s, *e; + size_t len; + + s = strchr(net_boot_file_name, '['); + e = strchr(net_boot_file_name, ']'); + if (s && e) { + len = e - s; + if (!string_to_ip6(s + 1, len - 1, &net_server_ip6)) + use_ip6 = true; + } + } + size = net_loop(proto); if (size < 0) { bootstage_error(BOOTSTAGE_ID_NET_NETLOOP_OK); diff --git a/net/net.c b/net/net.c index 63bf962b53..28c8dfdef2 100644 --- a/net/net.c +++ b/net/net.c @@ -1455,7 +1455,14 @@ static int net_check_prereq(enum proto_t protocol) /* Fall through */ case TFTPGET: case TFTPPUT: - if (net_server_ip.s_addr == 0 && !is_serverip_in_cmd()) { + if (IS_ENABLED(CONFIG_IPV6) && use_ip6) { + if (!memcmp(&net_server_ip6, &net_null_addr_ip6, + sizeof(struct in6_addr)) && + !strchr(net_boot_file_name, '[')) { + puts("*** ERROR: `serverip6' not set\n"); + return 1; + } + } else if (net_server_ip.s_addr == 0 && !is_serverip_in_cmd()) { puts("*** ERROR: `serverip' not set\n"); return 1; } @@ -1468,7 +1475,13 @@ common: case NETCONS: case FASTBOOT: case TFTPSRV: - if (net_ip.s_addr == 0) { + if (IS_ENABLED(CONFIG_IPV6) && use_ip6) { + if (!memcmp(&net_link_local_ip6, &net_null_addr_ip6, + sizeof(struct in6_addr))) { + puts("*** ERROR: `ip6addr` not set\n"); + return 1; + } + } else if (net_ip.s_addr == 0) { puts("*** ERROR: `ipaddr' not set\n"); return 1; } diff --git a/net/tftp.c b/net/tftp.c index 39421f8daa..c780c33f37 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include "bootp.h" @@ -41,6 +42,7 @@ DECLARE_GLOBAL_DATA_PTR; static ulong timeout_ms = TIMEOUT; static int timeout_count_max = (CONFIG_NET_RETRY_COUNT * 2); static ulong time_start; /* Record time we started tftp */ +static struct in6_addr tftp_remote_ip6; /* * These globals govern the timeout behavior when attempting a connection to a @@ -116,6 +118,7 @@ static int tftp_put_final_block_sent; /* default TFTP block size */ #define TFTP_BLOCK_SIZE 512 +#define TFTP_MTU_BLOCKSIZE6 (CONFIG_TFTP_BLOCKSIZE - 20) /* sequence number is 16 bit */ #define TFTP_SEQUENCE_SIZE ((ulong)(1<<16)) @@ -320,7 +323,11 @@ static void tftp_send(void) * We will always be sending some sort of packet, so * cobble together the packet headers now. */ - pkt = net_tx_packet + net_eth_hdr_size() + IP_UDP_HDR_SIZE; + if (IS_ENABLED(CONFIG_IPV6) && use_ip6) + pkt = net_tx_packet + net_eth_hdr_size() + + IP6_HDR_SIZE + UDP_HDR_SIZE; + else + pkt = net_tx_packet + net_eth_hdr_size() + IP_UDP_HDR_SIZE; switch (tftp_state) { case STATE_SEND_RRQ: @@ -422,8 +429,14 @@ static void tftp_send(void) break; } - net_send_udp_packet(net_server_ethaddr, tftp_remote_ip, - tftp_remote_port, tftp_our_port, len); + if (IS_ENABLED(CONFIG_IPV6) && use_ip6) + net_send_udp_packet6(net_server_ethaddr, + &tftp_remote_ip6, + tftp_remote_port, + tftp_our_port, len); + else + net_send_udp_packet(net_server_ethaddr, tftp_remote_ip, + tftp_remote_port, tftp_our_port, len); if (err_pkt) net_set_state(NETLOOP_FAIL); @@ -797,6 +810,9 @@ void tftp_start(enum proto_t protocol) debug("TFTP blocksize = %i, TFTP windowsize = %d timeout = %ld ms\n", tftp_block_size_option, tftp_window_size_option, timeout_ms); + if (IS_ENABLED(CONFIG_IPV6)) + tftp_remote_ip6 = net_server_ip6; + tftp_remote_ip = net_server_ip; if (!net_parse_bootfile(&tftp_remote_ip, tftp_filename, MAX_LEN)) { sprintf(default_filename, "%02X%02X%02X%02X.img", @@ -812,17 +828,49 @@ void tftp_start(enum proto_t protocol) tftp_filename); } + if (IS_ENABLED(CONFIG_IPV6)) { + if (use_ip6) { + char *s, *e; + size_t len; + + s = strchr(net_boot_file_name, '['); + e = strchr(net_boot_file_name, ']'); + len = e - s; + if (s && e) { + string_to_ip6(s + 1, len, &tftp_remote_ip6); + strlcpy(tftp_filename, e + 2, MAX_LEN); + } else { + strlcpy(tftp_filename, net_boot_file_name, MAX_LEN); + tftp_filename[MAX_LEN - 1] = 0; + } + } + } + printf("Using %s device\n", eth_get_name()); - printf("TFTP %s server %pI4; our IP address is %pI4", + + if (IS_ENABLED(CONFIG_IPV6) && use_ip6) { + printf("TFTP from server %pI6c; our IP address is %pI6c", + &tftp_remote_ip6, &net_ip6); + + if (tftp_block_size_option > TFTP_MTU_BLOCKSIZE6) + tftp_block_size_option = TFTP_MTU_BLOCKSIZE6; + } else { + printf("TFTP %s server %pI4; our IP address is %pI4", #ifdef CONFIG_CMD_TFTPPUT protocol == TFTPPUT ? "to" : "from", #else "from", #endif &tftp_remote_ip, &net_ip); + } /* Check if we need to send across this subnet */ - if (net_gateway.s_addr && net_netmask.s_addr) { + if (IS_ENABLED(CONFIG_IPV6) && use_ip6) { + if (!ip6_addr_in_subnet(&net_ip6, &tftp_remote_ip6, + net_prefix_length)) + printf("; sending through gateway %pI6c", + &net_gateway6); + } else if (net_gateway.s_addr && net_netmask.s_addr) { struct in_addr our_net; struct in_addr remote_net; From patchwork Fri Dec 2 09:18:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1711318 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=tGKHaQMX; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNnVw4f8Jz23nB for ; Fri, 2 Dec 2022 20:21:12 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 12A978544D; Fri, 2 Dec 2022 10:19:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="tGKHaQMX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3158D85452; Fri, 2 Dec 2022 10:19:18 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9AF7D85409 for ; Fri, 2 Dec 2022 10:18:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 47A6641207; Fri, 2 Dec 2022 09:18:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1669972736; x=1671787137; bh=sAW4T9PQsTgthHNvz4ehCHQPm fWK2UI28PGWegjDwP8=; b=tGKHaQMXsERNLcc/fGgjTXllWx3ncqLQX3KtmY/09 3/1dB6Qeg8dw8WPozdaNAzflH+dBhCGJAsM+n1KLuim7UKGg0IWhICs6/Eroqd9P Uwi8nB730j50iShPYCondVFrJv/yrCgMhrjKSuXD2TUAfkn0t3oCzNqSgE/FoH9M A8= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id g2k7zSQGy9Vc; Fri, 2 Dec 2022 12:18:56 +0300 (MSK) Received: from T-EXCH-01.corp.yadro.com (T-EXCH-01.corp.yadro.com [172.17.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id A847140311; Fri, 2 Dec 2022 12:18:56 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-01.corp.yadro.com (172.17.10.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 2 Dec 2022 12:18:56 +0300 Received: from v.yadro.com (10.178.114.10) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 2 Dec 2022 12:18:55 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , Subject: [PATCH v5 11/19] net: ping6: Add ping6 command Date: Fri, 2 Dec 2022 12:18:08 +0300 Message-ID: <20221202091818.2382748-12-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> References: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.178.114.10] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-Exch-05.corp.yadro.com (172.17.10.109) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Implement ping6 command to ping hosts using IPv6. It works the same way as an ordinary ping command. There is no ICMP request so it is not possible to ping our host. This patch adds options in Kconfig and Makefile to build ping6 command. Series-changes: 3 - Added structures and functions descriptions - Added to ping6_receive() return value instead of void Series-changes: 4 - Fixed structures and functions description style Signed-off-by: Viacheslav Mitrofanov Reviewed-by: Ramon Fried Reviewed-by: Simon Glass --- cmd/Kconfig | 7 +++ cmd/net.c | 26 +++++++++++ include/net.h | 4 +- include/net6.h | 26 +++++++++++ net/Makefile | 1 + net/net.c | 13 ++++++ net/net6.c | 4 ++ net/ping6.c | 118 +++++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 197 insertions(+), 2 deletions(-) create mode 100644 net/ping6.c diff --git a/cmd/Kconfig b/cmd/Kconfig index a4b6fc6a5d..d93731f2af 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1847,6 +1847,13 @@ config CMD_PING help Send ICMP ECHO_REQUEST to network host +config CMD_PING6 + bool "ping6" + depends on IPV6 + default y if (CMD_PING && IPV6) + help + Send ICMPv6 ECHO_REQUEST to network host + config CMD_CDP bool "cdp" help diff --git a/cmd/net.c b/cmd/net.c index 221b3525ca..0e9f200ca9 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -403,6 +403,32 @@ U_BOOT_CMD( ); #endif +#if IS_ENABLED(CONFIG_CMD_PING6) +int do_ping6(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) +{ + if (string_to_ip6(argv[1], strlen(argv[1]), &net_ping_ip6)) + return CMD_RET_USAGE; + + use_ip6 = true; + if (net_loop(PING6) < 0) { + use_ip6 = false; + printf("ping6 failed; host %pI6c is not alive\n", + &net_ping_ip6); + return 1; + } + + use_ip6 = false; + printf("host %pI6c is alive\n", &net_ping_ip6); + return 0; +} + +U_BOOT_CMD( + ping6, 2, 1, do_ping6, + "send ICMPv6 ECHO_REQUEST to network host", + "pingAddress" +); +#endif /* CONFIG_CMD_PING6 */ + #if defined(CONFIG_CMD_CDP) static void cdp_update_env(void) diff --git a/include/net.h b/include/net.h index e0c7804827..1a99009959 100644 --- a/include/net.h +++ b/include/net.h @@ -560,8 +560,8 @@ extern ushort net_native_vlan; /* Our Native VLAN */ extern int net_restart_wrap; /* Tried all network devices */ enum proto_t { - BOOTP, RARP, ARP, TFTPGET, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP, - TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT, WOL, UDP, NCSI, WGET + BOOTP, RARP, ARP, TFTPGET, DHCP, PING, PING6, DNS, NFS, CDP, NETCONS, + SNTP, TFTPSRV, TFTPPUT, LINKLOCAL, FASTBOOT, WOL, UDP, NCSI, WGET }; extern char net_boot_file_name[1024];/* Boot File name */ diff --git a/include/net6.h b/include/net6.h index 972eb42034..a249b590b3 100644 --- a/include/net6.h +++ b/include/net6.h @@ -172,6 +172,7 @@ extern struct in6_addr net_ip6; /* Our IPv6 addr (0 = unknown) */ extern struct in6_addr net_link_local_ip6; /* Our link local IPv6 addr */ extern u32 net_prefix_length; /* Our prefixlength (0 = unknown) */ extern struct in6_addr net_server_ip6; /* Server IPv6 addr (0 = unknown) */ +extern struct in6_addr net_ping_ip6; /* the ipv6 address to ping */ extern bool use_ip6; #if IS_ENABLED(CONFIG_IPV6) @@ -403,4 +404,29 @@ static inline void net_copy_ip6(void *to, const void *from) } #endif +#if IS_ENABLED(CONFIG_CMD_PING6) +/* Send ping requset */ +void ping6_start(void); + +/** + * ping6_receive() - Handle reception of ICMPv6 echo request/reply + * + * @et: pointer to incoming patcket + * @ip6: pointer to IPv6 protocol + * @len: packet length + * Return: 0 if success, -EINVAL in case of failure during reception + */ +int ping6_receive(struct ethernet_hdr *et, struct ip6_hdr *ip6, int len); +#else +static inline void ping6_start(void) +{ +} + +static inline +int ping6_receive(struct ethernet_hdr *et, struct ip6_hdr *ip6, int len) +{ + return -EINVAL; +} +#endif /* CONFIG_CMD_PING6 */ + #endif /* __NET6_H__ */ diff --git a/net/Makefile b/net/Makefile index df0ea500fe..13eef04029 100644 --- a/net/Makefile +++ b/net/Makefile @@ -25,6 +25,7 @@ obj-$(CONFIG_NET) += net.o obj-$(CONFIG_IPV6) += net6.o obj-$(CONFIG_CMD_NFS) += nfs.o obj-$(CONFIG_CMD_PING) += ping.o +obj-$(CONFIG_CMD_PING6) += ping6.o obj-$(CONFIG_CMD_PCAP) += pcap.o obj-$(CONFIG_CMD_RARP) += rarp.o obj-$(CONFIG_CMD_SNTP) += sntp.o diff --git a/net/net.c b/net/net.c index 28c8dfdef2..1c39acc493 100644 --- a/net/net.c +++ b/net/net.c @@ -525,6 +525,11 @@ restart: ping_start(); break; #endif +#if defined(CONFIG_CMD_PING6) + case PING6: + ping6_start(); + break; +#endif #if defined(CONFIG_CMD_NFS) && !defined(CONFIG_SPL_BUILD) case NFS: nfs_start(); @@ -1434,6 +1439,14 @@ static int net_check_prereq(enum proto_t protocol) } goto common; #endif +#if defined(CONFIG_CMD_PING6) + case PING6: + if (ip6_is_unspecified_addr(&net_ping_ip6)) { + puts("*** ERROR: ping address not given\n"); + return 1; + } + goto common; +#endif #if defined(CONFIG_CMD_DNS) case DNS: if (net_dns_server.s_addr == 0) { diff --git a/net/net6.c b/net/net6.c index e604227fe5..fdea078788 100644 --- a/net/net6.c +++ b/net/net6.c @@ -404,6 +404,10 @@ int net_ip6_handler(struct ethernet_hdr *et, struct ip6_hdr *ip6, int len) return -EINVAL; switch (icmp->icmp6_type) { + case IPV6_ICMP_ECHO_REQUEST: + case IPV6_ICMP_ECHO_REPLY: + ping6_receive(et, ip6, len); + break; case IPV6_NDISC_NEIGHBOUR_SOLICITATION: case IPV6_NDISC_NEIGHBOUR_ADVERTISEMENT: ndisc_receive(et, ip6, len); diff --git a/net/ping6.c b/net/ping6.c new file mode 100644 index 0000000000..4882a17f51 --- /dev/null +++ b/net/ping6.c @@ -0,0 +1,118 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2013 Allied Telesis Labs NZ + * Chris Packham, + * + * Copyright (C) 2022 YADRO + * Viacheslav Mitrofanov + */ + +/* Simple ping6 implementation */ + +#include +#include +#include +#include "ndisc.h" + +static ushort seq_no; + +/* the ipv6 address to ping */ +struct in6_addr net_ping_ip6; + +int +ip6_make_ping(uchar *eth_dst_addr, struct in6_addr *neigh_addr, uchar *pkt) +{ + struct echo_msg *msg; + u16 len; + u16 csum_p; + uchar *pkt_old = pkt; + + len = sizeof(struct echo_msg); + + pkt += net_set_ether(pkt, eth_dst_addr, PROT_IP6); + pkt += ip6_add_hdr(pkt, &net_ip6, neigh_addr, PROT_ICMPV6, + IPV6_NDISC_HOPLIMIT, len); + + /* ICMPv6 - Echo */ + msg = (struct echo_msg *)pkt; + msg->icmph.icmp6_type = IPV6_ICMP_ECHO_REQUEST; + msg->icmph.icmp6_code = 0; + msg->icmph.icmp6_cksum = 0; + msg->icmph.icmp6_identifier = 0; + msg->icmph.icmp6_sequence = htons(seq_no++); + msg->id = msg->icmph.icmp6_identifier; /* these seem redundant */ + msg->sequence = msg->icmph.icmp6_sequence; + + /* checksum */ + csum_p = csum_partial((u8 *)msg, len, 0); + msg->icmph.icmp6_cksum = csum_ipv6_magic(&net_ip6, neigh_addr, len, + PROT_ICMPV6, csum_p); + + pkt += len; + + return pkt - pkt_old; +} + +int ping6_send(void) +{ + uchar *pkt; + static uchar mac[6]; + + /* always send neighbor solicit */ + + memcpy(mac, net_null_ethaddr, 6); + + net_nd_sol_packet_ip6 = net_ping_ip6; + net_nd_packet_mac = mac; + + pkt = net_nd_tx_packet; + pkt += ip6_make_ping(mac, &net_ping_ip6, pkt); + + /* size of the waiting packet */ + net_nd_tx_packet_size = (pkt - net_nd_tx_packet); + + /* and do the ARP request */ + net_nd_try = 1; + net_nd_timer_start = get_timer(0); + ndisc_request(); + return 1; /* waiting */ +} + +static void ping6_timeout(void) +{ + eth_halt(); + net_set_state(NETLOOP_FAIL); /* we did not get the reply */ +} + +void ping6_start(void) +{ + printf("Using %s device\n", eth_get_name()); + net_set_timeout_handler(10000UL, ping6_timeout); + + ping6_send(); +} + +int ping6_receive(struct ethernet_hdr *et, struct ip6_hdr *ip6, int len) +{ + struct icmp6hdr *icmp = + (struct icmp6hdr *)(((uchar *)ip6) + IP6_HDR_SIZE); + struct in6_addr src_ip; + + switch (icmp->icmp6_type) { + case IPV6_ICMP_ECHO_REPLY: + src_ip = ip6->saddr; + if (memcmp(&net_ping_ip6, &src_ip, sizeof(struct in6_addr))) + return -EINVAL; + net_set_state(NETLOOP_SUCCESS); + break; + case IPV6_ICMP_ECHO_REQUEST: + /* ignore for now.... */ + debug("Got ICMPv6 ECHO REQUEST from %pI6c\n", &ip6->saddr); + return -EINVAL; + default: + debug("Unexpected ICMPv6 type 0x%x\n", icmp->icmp6_type); + return -EINVAL; + } + + return 0; +} From patchwork Fri Dec 2 09:18:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1711319 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=n5yBpDde; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNnW82fNvz23nB for ; Fri, 2 Dec 2022 20:21:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CACCE85424; Fri, 2 Dec 2022 10:19:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="n5yBpDde"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 79D5885459; Fri, 2 Dec 2022 10:19:21 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3806F85340 for ; Fri, 2 Dec 2022 10:18:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id C98E340311; Fri, 2 Dec 2022 09:18:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1669972737; x=1671787138; bh=mVTBZggc5kBymFpl3SnHFJWNW mL95UsQZq2kUyVI0VA=; b=n5yBpDdenRtpWVafTtgeoDJIU3HqFgCicUksTWUKk Yu03+wzLEDAXzcW8nlaYU6j6c9zFb5BnlSxkxvlO7HiPeF01KTwGguSPBnIby9n9 YJ2AKbMxWs+ylVUXNJYOTcvUoLUBQDzj3uqfW9CEjn1E/Xo6evIU9Ae+3XlB/0Mi I4= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tlg_2eQaqCWF; Fri, 2 Dec 2022 12:18:57 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (T-EXCH-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 9F3DC41200; Fri, 2 Dec 2022 12:18:57 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 2 Dec 2022 12:18:57 +0300 Received: from v.yadro.com (10.178.114.10) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 2 Dec 2022 12:18:56 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , Subject: [PATCH v5 12/19] test: dm: eth: Add string_to_ip6 test Date: Fri, 2 Dec 2022 12:18:09 +0300 Message-ID: <20221202091818.2382748-13-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> References: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.178.114.10] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-Exch-05.corp.yadro.com (172.17.10.109) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Add a test to check convertation from char* to struct in6_addr. Use in sandbox Series-changes: 3 - Fixed tests to use length param in string_to_ip6() Series-changes: 5 - Add test under #ifdef Signed-off-by: Viacheslav Mitrofanov Reviewed-by: Ramon Fried Reviewed-by: Simon Glass --- test/dm/eth.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/test/dm/eth.c b/test/dm/eth.c index 5437f9ea4a..7015aac701 100644 --- a/test/dm/eth.c +++ b/test/dm/eth.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,61 @@ #define DM_TEST_ETH_NUM 4 +#if IS_ENABLED(CONFIG_IPV6) +static int dm_test_string_to_ip6(struct unit_test_state *uts) +{ + char *str; + struct test_ip6_pair + { + char *string_addr; + struct in6_addr ip6_addr; + }; + + struct in6_addr ip6 = {0}; + + /* Correct statements */ + struct test_ip6_pair test_suite[] = { + {"2001:db8::0:1234:1", {.s6_addr32[0] = 0xb80d0120, + .s6_addr32[1] = 0x00000000, + .s6_addr32[2] = 0x00000000, + .s6_addr32[3] = 0x01003412}}, + {"2001:0db8:0000:0000:0000:0000:1234:0001", + {.s6_addr32[0] = 0xb80d0120, + .s6_addr32[1] = 0x00000000, + .s6_addr32[2] = 0x00000000, + .s6_addr32[3] = 0x01003412}}, + {"::1", {.s6_addr32[0] = 0x00000000, + .s6_addr32[1] = 0x00000000, + .s6_addr32[2] = 0x00000000, + .s6_addr32[3] = 0x01000000}}, + {"::ffff:192.168.1.1", {.s6_addr32[0] = 0x00000000, + .s6_addr32[1] = 0x00000000, + .s6_addr32[2] = 0xffff0000, + .s6_addr32[3] = 0x0101a8c0}}, + }; + + for (int i = 0; i < ARRAY_SIZE(test_suite); ++i) { + ut_assertok(string_to_ip6(test_suite[i].string_addr, + strlen(test_suite[i].string_addr), &ip6)); + ut_asserteq_mem(&ip6, &test_suite[i].ip6_addr, + sizeof(struct in6_addr)); + } + + /* Incorrect statements */ + str = "hello:world"; + ut_assertok(!string_to_ip6(str, strlen(str), &ip6)); + str = "2001:db8::0::0"; + ut_assertok(!string_to_ip6(str, strlen(str), &ip6)); + str = "2001:db8:192.168.1.1::1"; + ut_assertok(!string_to_ip6(str, strlen(str), &ip6)); + str = "192.168.1.1"; + ut_assertok(!string_to_ip6(str, strlen(str), &ip6)); + + return 0; +} +DM_TEST(dm_test_string_to_ip6, 0); +#endif + static int dm_test_eth(struct unit_test_state *uts) { net_ping_ip = string_to_ip("1.1.2.2"); From patchwork Fri Dec 2 09:18:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1711320 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=EitwUrpT; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNnWN6bZdz23nB for ; Fri, 2 Dec 2022 20:21:36 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 24393853D0; Fri, 2 Dec 2022 10:19:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="EitwUrpT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 85ABA8542D; Fri, 2 Dec 2022 10:19:24 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7CB6D853C8 for ; Fri, 2 Dec 2022 10:19:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id DED2F411FF; Fri, 2 Dec 2022 09:19:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1669972740; x=1671787141; bh=xBEsl5jYotUE4Pm7TvcKiOdzv iD44AP8DdoCmGwoP4M=; b=EitwUrpTuPuDOQST1j4QP+Q+XBMbRyYj2nHtYQHYf 81VYRjxG3NG5H6oJ80rZKp0o9qpwkyTh4iMCuDf+fMecjELF6VnRvvdgOBMDXKTM bPt/VEyVm6mI5fTX2PF4hOKDFJsyI+c5iqgcynVqIHOAV8z9CtS45C1tdbnK+Kn/ Eg= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7A3j6YeRAVE6; Fri, 2 Dec 2022 12:19:00 +0300 (MSK) Received: from T-EXCH-01.corp.yadro.com (T-EXCH-01.corp.yadro.com [172.17.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id EA83240889; Fri, 2 Dec 2022 12:18:59 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-01.corp.yadro.com (172.17.10.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 2 Dec 2022 12:18:59 +0300 Received: from v.yadro.com (10.178.114.10) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 2 Dec 2022 12:18:57 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , Subject: [PATCH v5 13/19] test: dm: eth: Add csum_ipv6_magic test Date: Fri, 2 Dec 2022 12:18:10 +0300 Message-ID: <20221202091818.2382748-14-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> References: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.178.114.10] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-Exch-05.corp.yadro.com (172.17.10.109) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Test checksum computation. csum_ipv6_magic() uses in upper layer protocols as TCP/UDP/ICMPv6/etc to calculate payload checksum. Series-changes: 3 - Fixed style problems Signed-off-by: Viacheslav Mitrofanov Reviewed-by: Ramon Fried Reviewed-by: Simon Glass --- test/dm/eth.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/dm/eth.c b/test/dm/eth.c index 7015aac701..04302cd74a 100644 --- a/test/dm/eth.c +++ b/test/dm/eth.c @@ -76,6 +76,35 @@ static int dm_test_string_to_ip6(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_string_to_ip6, 0); + +static int dm_test_csum_ipv6_magic(struct unit_test_state *uts) +{ + unsigned short csum = 0xbeef; + /* Predefined correct parameters */ + unsigned short correct_csum = 0xd8ac; + struct in6_addr saddr = {.s6_addr32[0] = 0x000080fe, + .s6_addr32[1] = 0x00000000, + .s6_addr32[2] = 0xffe9f242, + .s6_addr32[3] = 0xe8f66dfe}; + struct in6_addr daddr = {.s6_addr32[0] = 0x000080fe, + .s6_addr32[1] = 0x00000000, + .s6_addr32[2] = 0xffd5b372, + .s6_addr32[3] = 0x3ef692fe}; + u16 len = 1460; + unsigned short proto = 17; + unsigned int head_csum = 0x91f0; + + csum = csum_ipv6_magic(&saddr, &daddr, len, proto, head_csum); + ut_asserteq(csum, correct_csum); + + /* Broke a parameter */ + proto--; + csum = csum_ipv6_magic(&saddr, &daddr, len, proto, head_csum); + ut_assert(csum != correct_csum); + + return 0; +} +DM_TEST(dm_test_csum_ipv6_magic, 0); #endif static int dm_test_eth(struct unit_test_state *uts) From patchwork Fri Dec 2 09:18:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1711322 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=JhRkHoXA; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNnWb38gmz23nB for ; Fri, 2 Dec 2022 20:21:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9791D8544A; Fri, 2 Dec 2022 10:19:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="JhRkHoXA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 80DDC8542D; Fri, 2 Dec 2022 10:19:26 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C17F285424 for ; Fri, 2 Dec 2022 10:19:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 6743840311; Fri, 2 Dec 2022 09:19:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1669972742; x=1671787143; bh=tXj6/mH59GV5sE8mAIvuPLFZr 59aE+CSVbiYXzgn6sU=; b=JhRkHoXAGTkLk9u/4TyIJRCgP1VOxcNGI4MFoiOIq nCL2x3zpOYpt43KxvTzwyN5sAUqZvA/ZKA/6VWz66mJssJvBfnfHgK9p65PjDHee W78O2VQCy6UjB9PMNLEoJegH34USHJPj3bgnibssry44lhP5eHjjjcVjAB+LidI2 Go= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kkBUubcBxbB4; Fri, 2 Dec 2022 12:19:02 +0300 (MSK) Received: from T-EXCH-01.corp.yadro.com (T-EXCH-01.corp.yadro.com [172.17.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 5E71340889; Fri, 2 Dec 2022 12:19:02 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-01.corp.yadro.com (172.17.10.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 2 Dec 2022 12:19:01 +0300 Received: from v.yadro.com (10.178.114.10) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 2 Dec 2022 12:19:00 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , Subject: [PATCH v5 14/19] test: dm: eth: Add ip6_addr_in_subnet test Date: Fri, 2 Dec 2022 12:18:11 +0300 Message-ID: <20221202091818.2382748-15-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> References: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.178.114.10] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-Exch-05.corp.yadro.com (172.17.10.109) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Add a test if two address are in the same subnet. Use in sandbox Signed-off-by: Viacheslav Mitrofanov Reviewed-by: Ramon Fried Reviewed-by: Simon Glass --- test/dm/eth.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/dm/eth.c b/test/dm/eth.c index 04302cd74a..9a055cbb16 100644 --- a/test/dm/eth.c +++ b/test/dm/eth.c @@ -105,6 +105,31 @@ static int dm_test_csum_ipv6_magic(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_csum_ipv6_magic, 0); + +static int dm_test_ip6_addr_in_subnet(struct unit_test_state *uts) +{ + struct in6_addr our = {.s6_addr32[0] = 0x000080fe, + .s6_addr32[1] = 0x00000000, + .s6_addr32[2] = 0xffe9f242, + .s6_addr32[3] = 0xe8f66dfe}; + struct in6_addr neigh1 = {.s6_addr32[0] = 0x000080fe, + .s6_addr32[1] = 0x00000000, + .s6_addr32[2] = 0xffd5b372, + .s6_addr32[3] = 0x3ef692fe}; + struct in6_addr neigh2 = {.s6_addr32[0] = 0x60480120, + .s6_addr32[1] = 0x00006048, + .s6_addr32[2] = 0x00000000, + .s6_addr32[3] = 0x00008888}; + + /* in */ + ut_assert(ip6_addr_in_subnet(&our, &neigh1, 64)); + /* outside */ + ut_assert(!ip6_addr_in_subnet(&our, &neigh2, 64)); + ut_assert(!ip6_addr_in_subnet(&our, &neigh1, 128)); + + return 0; +} +DM_TEST(dm_test_ip6_addr_in_subnet, 0); #endif static int dm_test_eth(struct unit_test_state *uts) From patchwork Fri Dec 2 09:18:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1711324 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=Q3p+ys4B; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNnX234mBz23nB for ; Fri, 2 Dec 2022 20:22:10 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 273FE85423; Fri, 2 Dec 2022 10:19:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="Q3p+ys4B"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B4FAF85463; Fri, 2 Dec 2022 10:19:29 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0CDAA85403 for ; Fri, 2 Dec 2022 10:19:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 754D84120A; Fri, 2 Dec 2022 09:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1669972743; x=1671787144; bh=WkjrLDvtfRTLVMOq2PpYsqrX0 rG4wqbQ8dXpuhRJyUg=; b=Q3p+ys4BcEkQ1tjY2E7+ve4+wjDbl7yXjTTLTiAIm vjhNpHwKeDDGxeHU8FmzxQGbaOHUypVuB2GjlZ9XXgs0ShOKIsgNoHIW/4/W9OnT hdv1i+wBjC7uGfkokHc3G84vpRR8JMzdqJuIbT60NVAAGHWUELuGTM0tvr0atYQ1 Jc= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id p8CfABeH7RUv; Fri, 2 Dec 2022 12:19:03 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (T-EXCH-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 6F5C64088A; Fri, 2 Dec 2022 12:19:02 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 2 Dec 2022 12:19:02 +0300 Received: from v.yadro.com (10.178.114.10) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 2 Dec 2022 12:19:01 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , Subject: [PATCH v5 15/19] test: dm: eth: Add ip6_make_snma test Date: Fri, 2 Dec 2022 12:18:12 +0300 Message-ID: <20221202091818.2382748-16-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> References: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.178.114.10] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-Exch-05.corp.yadro.com (172.17.10.109) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Add a test that checks generated Solicited Node Multicast Address from our ipv6 address. Use in sandbox Signed-off-by: Viacheslav Mitrofanov Reviewed-by: Ramon Fried Reviewed-by: Simon Glass --- test/dm/eth.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/dm/eth.c b/test/dm/eth.c index 9a055cbb16..4b9e80ae2d 100644 --- a/test/dm/eth.c +++ b/test/dm/eth.c @@ -130,6 +130,26 @@ static int dm_test_ip6_addr_in_subnet(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_ip6_addr_in_subnet, 0); + +static int dm_test_ip6_make_snma(struct unit_test_state *uts) +{ + struct in6_addr mult = {0}; + struct in6_addr correct_addr = { + .s6_addr32[0] = 0x000002ff, + .s6_addr32[1] = 0x00000000, + .s6_addr32[2] = 0x01000000, + .s6_addr32[3] = 0xe8f66dff}; + struct in6_addr addr = { .s6_addr32[0] = 0x000080fe, + .s6_addr32[1] = 0x00000000, + .s6_addr32[2] = 0xffe9f242, + .s6_addr32[3] = 0xe8f66dfe}; + + ip6_make_snma(&mult, &addr); + ut_asserteq_mem(&mult, &correct_addr, sizeof(struct in6_addr)); + + return 0; +} +DM_TEST(dm_test_ip6_make_snma, 0); #endif static int dm_test_eth(struct unit_test_state *uts) From patchwork Fri Dec 2 09:18:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1711323 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=c+rdqJgz; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNnWp3f6Hz23nB for ; Fri, 2 Dec 2022 20:21:58 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 305FE8545E; Fri, 2 Dec 2022 10:19:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="c+rdqJgz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DFD968545E; Fri, 2 Dec 2022 10:19:28 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4DB5485449 for ; Fri, 2 Dec 2022 10:19:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 1B577411FF; Fri, 2 Dec 2022 09:19:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1669972748; x=1671787149; bh=8ndwlFvEdnRFDyp6lCo3KEhrl bb7MdG9/PbXyLWpj4Q=; b=c+rdqJgzXwoByV6o825O+e1sr2Ejhpg/5wfT0tuFf yvCJudHDhm900xVteepPBiG0BEd/VUUkqlMZbjI9jvAAkLZEZ/TzQIBi7qcPNwbR a2PEIuxGzGdHAgaq+JYtDbQlRpwgaSPka/WKOy9Sqtp/IXhnG/AsoPq6yZmeQmUi 4E= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DpKSSJFo9CL5; Fri, 2 Dec 2022 12:19:08 +0300 (MSK) Received: from T-EXCH-01.corp.yadro.com (T-EXCH-01.corp.yadro.com [172.17.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 97DA141209; Fri, 2 Dec 2022 12:19:03 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-01.corp.yadro.com (172.17.10.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 2 Dec 2022 12:19:03 +0300 Received: from v.yadro.com (10.178.114.10) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 2 Dec 2022 12:19:02 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , Subject: [PATCH v5 16/19] test: dm: eth: Add ip6_make_lladdr test Date: Fri, 2 Dec 2022 12:18:13 +0300 Message-ID: <20221202091818.2382748-17-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> References: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.178.114.10] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-Exch-05.corp.yadro.com (172.17.10.109) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Add a test that checks generated Link Local Address. Use in sandbox Signed-off-by: Viacheslav Mitrofanov Reviewed-by: Ramon Fried Reviewed-by: Simon Glass --- test/dm/eth.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/dm/eth.c b/test/dm/eth.c index 4b9e80ae2d..480263f446 100644 --- a/test/dm/eth.c +++ b/test/dm/eth.c @@ -150,6 +150,24 @@ static int dm_test_ip6_make_snma(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_ip6_make_snma, 0); + +static int dm_test_ip6_make_lladdr(struct unit_test_state *uts) +{ + struct in6_addr generated_lladdr = {0}; + struct in6_addr correct_lladdr = { + .s6_addr32[0] = 0x000080fe, + .s6_addr32[1] = 0x00000000, + .s6_addr32[2] = 0xffabf33a, + .s6_addr32[3] = 0xfbb352fe}; + const unsigned char mac[6] = {0x38, 0xf3, 0xab, 0x52, 0xb3, 0xfb}; + + ip6_make_lladdr(&generated_lladdr, mac); + ut_asserteq_mem(&generated_lladdr, &correct_lladdr, + sizeof(struct in6_addr)); + + return 0; +} +DM_TEST(dm_test_ip6_make_lladdr, UT_TESTF_SCAN_FDT); #endif static int dm_test_eth(struct unit_test_state *uts) From patchwork Fri Dec 2 09:18:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1711325 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=Vlvn7aoA; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNnXG2NmWz23nB for ; Fri, 2 Dec 2022 20:22:22 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 934E385470; Fri, 2 Dec 2022 10:19:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="Vlvn7aoA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8851D853C2; Fri, 2 Dec 2022 10:19:33 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3042F85456 for ; Fri, 2 Dec 2022 10:19:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 10AF741200; Fri, 2 Dec 2022 09:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1669972749; x=1671787150; bh=H6NtemjON1imUKZwZsh3aRtHC PHPRlsIPNvODaPn0y0=; b=Vlvn7aoAeSPkR6OFWvSWAAajJ7tiIVXd/sMEMCZ2n JNWmKgayU1veVdMaDVMfx4ji3fjy75rdZjEoFrA6KKpjuwuEozRIABMh5JKIEeOe iBTHzT3slM4kdQPJALOhAssGKBs2Pap6KCZTLIFCtDOmeiWv5ZaLZN9g4W3C1adS 7o= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UJZnwCFsRLE7; Fri, 2 Dec 2022 12:19:09 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (T-EXCH-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id A4C4B4088A; Fri, 2 Dec 2022 12:19:04 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 2 Dec 2022 12:19:04 +0300 Received: from v.yadro.com (10.178.114.10) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 2 Dec 2022 12:19:03 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , Subject: [PATCH v5 17/19] configs: Add IPV6 config to sandbox_defconfig Date: Fri, 2 Dec 2022 12:18:14 +0300 Message-ID: <20221202091818.2382748-18-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> References: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.178.114.10] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-Exch-05.corp.yadro.com (172.17.10.109) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Allow to use IPV6 tests in sandbox Signed-off-by: Viacheslav Mitrofanov --- configs/sandbox_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 07fe0c3a7a..404e4a3324 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -333,3 +333,4 @@ CONFIG_TEST_FDTDEC=y CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y +CONFIG_IPV6=y From patchwork Fri Dec 2 09:18:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1711327 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=bwmEkNr6; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNnXj5JHYz23nB for ; Fri, 2 Dec 2022 20:22:45 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CCBCF85473; Fri, 2 Dec 2022 10:19:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="bwmEkNr6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7ED0C8540D; Fri, 2 Dec 2022 10:19:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8557F85338 for ; Fri, 2 Dec 2022 10:19:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 8A13541209; Fri, 2 Dec 2022 09:19:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1669972753; x=1671787154; bh=0+pEeKFxUmsigLyN3PQ281tBQ 3XVm2y6mrBBnCQgBRM=; b=bwmEkNr6kqQy2Z15IuMKno/uZ8qkCpDn0RoI+ii33 exlkDq6o4B8LkyvajzBA8HYenY86qoK+PpRderJ+HMLrntpcmLybiOdC+eHIDX+Q cx8SyPdBboN8Q1gT3DsHOMR+YTsILDRSvqcCxJKiB4+0C87XR0l8iYMtAx1MPR++ LA= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VLuSsOul9LEg; Fri, 2 Dec 2022 12:19:13 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (T-EXCH-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id C86A14120E; Fri, 2 Dec 2022 12:19:06 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 2 Dec 2022 12:19:06 +0300 Received: from v.yadro.com (10.178.114.10) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 2 Dec 2022 12:19:05 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , Subject: [PATCH v5 18/19] configs: Add IPV6 config to sandbox64_defconfig Date: Fri, 2 Dec 2022 12:18:16 +0300 Message-ID: <20221202091818.2382748-20-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> References: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.178.114.10] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-Exch-05.corp.yadro.com (172.17.10.109) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Allow to use IPV6 tests in sandbox Signed-off-by: Viacheslav Mitrofanov --- configs/sandbox64_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig index cff166b1c1..b69e053126 100644 --- a/configs/sandbox64_defconfig +++ b/configs/sandbox64_defconfig @@ -258,3 +258,4 @@ CONFIG_FWU_MULTI_BANK_UPDATE=y CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y +CONFIG_IPV6=y From patchwork Fri Dec 2 09:18:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vyacheslav V. Mitrofanov" X-Patchwork-Id: 1711328 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.a=rsa-sha256 header.s=mta-01 header.b=IO3D01gb; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNnXw6qfSz23nB for ; Fri, 2 Dec 2022 20:22:56 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DA9038547C; Fri, 2 Dec 2022 10:19:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=yadro.com header.i=@yadro.com header.b="IO3D01gb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6F60B85334; Fri, 2 Dec 2022 10:19:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mta-01.yadro.com (mta-02.yadro.com [89.207.88.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5535085448 for ; Fri, 2 Dec 2022 10:19:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=yadro.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=v.v.mitrofanov@yadro.com Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 8835E41207; Fri, 2 Dec 2022 09:19:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received:received; s= mta-01; t=1669972754; x=1671787155; bh=VwT6SHDufNQVpiCsfj8vaAVFw 4BF5cHGK52AS9D3MEo=; b=IO3D01gbxggFKqbDRu8DSd4F7T/Dg5W67AxWXnUvp UlKhQHklDSQgMpeEjHJJgsMjp1Gtqc/yOdflDQNq/635GLe0B5E/DdVloNovbFDV HR/fti0PXG75xz/UfG6QwAJGb05O8xMqnAnCC7WM9iXduj2xgCuqsMtw4cEY+LeO Po= Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Vd4ydmsakWwZ; Fri, 2 Dec 2022 12:19:14 +0300 (MSK) Received: from T-EXCH-01.corp.yadro.com (T-EXCH-01.corp.yadro.com [172.17.10.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id 2D76440889; Fri, 2 Dec 2022 12:19:08 +0300 (MSK) Received: from T-Exch-05.corp.yadro.com (172.17.10.109) by T-EXCH-01.corp.yadro.com (172.17.10.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Fri, 2 Dec 2022 12:19:08 +0300 Received: from v.yadro.com (10.178.114.10) by T-Exch-05.corp.yadro.com (172.17.10.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.1118.9; Fri, 2 Dec 2022 12:19:07 +0300 From: Viacheslav Mitrofanov To: CC: , , , , , , Subject: [PATCH v5 19/19] configs: Add IPV6 config to sandbox_flattree_defconfig Date: Fri, 2 Dec 2022 12:18:17 +0300 Message-ID: <20221202091818.2382748-21-v.v.mitrofanov@yadro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> References: <20221202091818.2382748-1-v.v.mitrofanov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [10.178.114.10] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-Exch-05.corp.yadro.com (172.17.10.109) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Allow to use IPV6 tests in sandbox Signed-off-by: Viacheslav Mitrofanov --- configs/sandbox_flattree_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index 01234dc183..7237efe685 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -216,3 +216,4 @@ CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y +CONFIG_IPV6=y