1
0
mirror of https://github.com/systemd/systemd synced 2026-03-25 08:14:54 +01:00

Compare commits

..

21 Commits

Author SHA1 Message Date
Yu Watanabe
7c58ee5f8c
Merge pull request #20443 from yuwata/network-conf-parser-cleanups
network: conf parser cleanups
2021-08-17 02:42:27 +09:00
Geass-LL
7dbd330c7e unit: coldplug both job and nop_job if possible
Sometimes, both job and nop_job are deserialized. In this case,
if we only cold plug the job, the nop_job will also stuck in the
job list.
2021-08-17 02:41:04 +09:00
Yu Watanabe
aa10fa8d3a
Merge pull request #20442 from yuwata/network-can-introduce-many-settings
network: introduce several CAN interface related settings
2021-08-17 02:40:32 +09:00
Maxime de Roucy
d419ef0243 network: add address label on dhcpv4
Fixes: #13967
2021-08-17 02:40:18 +09:00
Tom Yan
17a6a4ae2e network: allow users to forbid passthru MACVLAN from putting its link into promiscuous mode
While we haven't implemented a key for users to set MACVLAN/MACVTAP flags,
we can at least allow them to make use of the Promiscuous= key of
the corresponding link to set the nopromisc flag.
2021-08-16 17:26:59 +01:00
Yu Watanabe
80e41a68d6 man: address label can be set only for IPv4 addresses 2021-08-16 22:56:30 +09:00
Lennart Poettering
682f952cd7
Merge pull request #20438 from medhefgo/boot
sd-boot: Better self-detection and windows loader title
2021-08-16 15:35:08 +02:00
Yu Watanabe
b164b570b4 network: can: allow to specify bit-timing with TimeQuantaNSec= and friends
Closes #19424 and #20435.
2021-08-16 22:30:38 +09:00
Yu Watanabe
817561cc60 network: SamplePoint= should be specified only when BitRate= is specified
See can_get_bittiming() in drivers/net/can/dev/bittiming.c of kernel.
2021-08-16 18:54:01 +09:00
Yu Watanabe
239f91f71c network: can: make Termination= optionally take a raw resistor value
Note that this slightly breaks backward compatibility when
Termination=1. Previously, this is handled as boolean true, then 120 ohm
was used. But now with this commit, it is handled as 1 ohm.
2021-08-16 18:52:24 +09:00
Yu Watanabe
6dd84c9e86 network: can: add missing control modes 2021-08-16 18:42:48 +09:00
Yu Watanabe
f1c141cb82 network: can: introduce config_parse_can_control_mode() 2021-08-16 18:42:48 +09:00
Yu Watanabe
0fa2984dad network: can: refuse too large restart sec earlier 2021-08-16 18:42:45 +09:00
Jan Janssen
4a59f399c9 sd-boot: Detect windows boot loader title from BCD 2021-08-16 10:51:02 +02:00
Jan Janssen
43ee1fe086 sd-boot: Add memmem_safe and memory_startswith 2021-08-16 10:50:58 +02:00
Jan Janssen
12450f2e77 sd-boot: Try harder to detect ourselves
By moving our magic string into its own PE section, we can forego
grepping for it.
2021-08-16 10:49:18 +02:00
Jan Janssen
1328150d85 sd-boot: Fix PE section parsing
We only need the PE header offset from the DOS header, not
its size. Previously, the section table could be cut off in the middle.

While we are at it, also modernize the remaining code.
2021-08-16 10:49:12 +02:00
Yu Watanabe
b40b8b06cb network: check validity before copying the input string
Prompted by https://github.com/systemd/systemd/pull/20440#discussion_r689136337.
2021-08-16 13:48:15 +09:00
Yu Watanabe
634815762d network: rebreak conf parser arguments 2021-08-16 12:54:09 +09:00
Yu Watanabe
952508abda network: can: move function 2021-08-16 01:07:06 +09:00
Yu Watanabe
4931217a67 basic/linux: update linux uapi headers 2021-08-16 01:07:06 +09:00
49 changed files with 1952 additions and 1001 deletions

View File

@ -1053,7 +1053,8 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></para>
<varlistentry>
<term><varname>Label=</varname></term>
<listitem>
<para>An address label.</para>
<para>Specifies the label for the IPv4 address. The label must be a 7-bit ASCII string with
a length of 1…15 characters. Defaults to unset.</para>
</listitem>
</varlistentry>
<varlistentry>
@ -1770,6 +1771,15 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></para>
<!-- How to use the DHCP lease -->
<varlistentry>
<term><varname>Label=</varname></term>
<listitem>
<para>Specifies the label for the IPv4 address received from the DHCP server.
The label must be a 7-bit ASCII string with a length of 1…15 characters.
Defaults to unset.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>UseDNS=</varname></term>
<listitem>
@ -2957,7 +2967,27 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></para>
<term><varname>SamplePoint=</varname></term>
<listitem>
<para>Optional sample point in percent with one decimal (e.g. <literal>75%</literal>,
<literal>87.5%</literal>) or permille (e.g. <literal>875‰</literal>).</para>
<literal>87.5%</literal>) or permille (e.g. <literal>875‰</literal>). This will be ignored when
<varname>BitRate=</varname> is unspecified.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>TimeQuantaNSec=</varname></term>
<term><varname>PropagationSegment=</varname></term>
<term><varname>PhaseBufferSegment1=</varname></term>
<term><varname>PhaseBufferSegment2=</varname></term>
<term><varname>SyncJumpWidth=</varname></term>
<listitem>
<para>Specifies the time quanta, propagation segment, phase buffer segment 1 and 2, and the
synchronization jump width, which allow to define the CAN bit-timing in a hardware
independent format as proposed by the Bosch CAN 2.0 Specification.
<varname>TimeQuantaNSec=</varname> takes a timespan in nanoseconds.
<varname>PropagationSegment=</varname>, <varname>PhaseBufferSegment1=</varname>,
<varname>PhaseBufferSegment2=</varname>, and <varname>SyncJumpWidth=</varname> take number
of time quantum specified in <varname>TimeQuantaNSec=</varname> and must be an unsigned
integer in the range 0…4294967295. These settings except for
<varname>SyncJumpWidth=</varname> will be ignored when <varname>BitRate=</varname> is
specified.</para>
</listitem>
</varlistentry>
<varlistentry>
@ -2968,12 +2998,25 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></para>
analogous to the <varname>BitRate=</varname> and <varname>SamplePoint=</varname> keys.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>DataTimeQuantaNSec=</varname></term>
<term><varname>DataPropagationSegment=</varname></term>
<term><varname>DataPhaseBufferSegment1=</varname></term>
<term><varname>DataPhaseBufferSegment2=</varname></term>
<term><varname>DataSyncJumpWidth=</varname></term>
<listitem>
<para>Specifies the time quanta, propagation segment, phase buffer segment 1 and 2, and the
synchronization jump width for the data phase, if CAN-FD is used. These settings are
analogous to the <varname>TimeQuantaNSec=</varname> or related settings.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>FDMode=</varname></term>
<listitem>
<para>Takes a boolean. When <literal>yes</literal>, CAN-FD mode is enabled for the interface.
Note, that a bitrate and optional sample point should also be set for the CAN-FD data phase using
the <varname>DataBitRate=</varname> and <varname>DataSamplePoint=</varname> keys.</para>
the <varname>DataBitRate=</varname> and <varname>DataSamplePoint=</varname> keys, or
<varname>DataTimeQuanta=</varname> and related settings.</para>
</listitem>
</varlistentry>
<varlistentry>
@ -2996,8 +3039,10 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></para>
<varlistentry>
<term><varname>Termination=</varname></term>
<listitem>
<para>Takes a boolean. When <literal>yes</literal>, the termination resistor will be selected for
the bias network. When unset, the kernel's default will be used.</para>
<para>Takes a boolean or a termination resistor value in ohm in the range 065535. When
<literal>yes</literal>, the termination resistor is set to 120 ohm. When
<literal>no</literal> or <literal>0</literal> is set, the termination resistor is disabled.
When unset, the kernel's default will be used.</para>
</listitem>
</varlistentry>
<varlistentry>
@ -3027,6 +3072,36 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></para>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>Loopback=</varname></term>
<listitem>
<para>Takes a boolean. When <literal>yes</literal>, loopback mode is enabled. When the
loopback mode is enabled, the interface treats messages transmitted by itself as received
messages. The loopback mode is important to debug CAN networks. When unset, the kernel's
default will be used.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>OneShot=</varname></term>
<listitem>
<para>Takes a boolean. When <literal>yes</literal>, one-shot mode is enabled. When unset,
the kernel's default will be used.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>PresumeAck=</varname></term>
<listitem>
<para>Takes a boolean. When <literal>yes</literal>, the interface will ignore missing CAN
ACKs. When unset, the kernel's default will be used.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>ClassicDataLengthCode=</varname></term>
<listitem>
<para>Takes a boolean. When <literal>yes</literal>, the interface will handle the 4bit data
length code (DLC). When unset, the kernel's default will be used.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

File diff suppressed because it is too large Load Diff

View File

@ -154,7 +154,7 @@ struct btrfs_scrub_progress {
__u64 tree_bytes_scrubbed; /* # of tree bytes scrubbed */
__u64 read_errors; /* # of read errors encountered (EIO) */
__u64 csum_errors; /* # of failed csum checks */
__u64 verify_errors; /* # of occurences, where the metadata
__u64 verify_errors; /* # of occurrences, where the metadata
* of a tree block did not match the
* expected values, like generation or
* logical */
@ -174,7 +174,7 @@ struct btrfs_scrub_progress {
__u64 last_physical; /* last physical address scrubbed. In
* case a scrub was aborted, this can
* be used to restart the scrub */
__u64 unverified_errors; /* # of occurences where a read for a
__u64 unverified_errors; /* # of occurrences where a read for a
* full (64k) bio failed, but the re-
* check succeeded for each 4k piece.
* Intermittent error. */
@ -307,6 +307,7 @@ struct btrfs_ioctl_fs_info_args {
#define BTRFS_FEATURE_INCOMPAT_NO_HOLES (1ULL << 9)
#define BTRFS_FEATURE_INCOMPAT_METADATA_UUID (1ULL << 10)
#define BTRFS_FEATURE_INCOMPAT_RAID1C34 (1ULL << 11)
#define BTRFS_FEATURE_INCOMPAT_ZONED (1ULL << 12)
struct btrfs_ioctl_feature_flags {
__u64 compat_flags;

View File

@ -59,7 +59,7 @@
/* for storing balance parameters in the root tree */
#define BTRFS_BALANCE_OBJECTID -4ULL
/* orhpan objectid for tracking unlinked/truncated files */
/* orphan objectid for tracking unlinked/truncated files */
#define BTRFS_ORPHAN_OBJECTID -5ULL
/* does write ahead logging to speed up fsyncs */
@ -275,7 +275,7 @@
#define BTRFS_PERSISTENT_ITEM_KEY 249
/*
* Persistantly stores the device replace state in the device tree.
* Persistently stores the device replace state in the device tree.
* The key is built like this: (0, BTRFS_DEV_REPLACE_KEY, 0).
*/
#define BTRFS_DEV_REPLACE_KEY 250
@ -299,7 +299,8 @@
*/
#define BTRFS_STRING_ITEM_KEY 253
/* Maximum metadata block size (nodesize) */
#define BTRFS_MAX_METADATA_BLOCKSIZE 65536
/* 32 bytes in various csum fields */
#define BTRFS_CSUM_SIZE 32

View File

@ -100,6 +100,7 @@ struct can_ctrlmode {
#define CAN_CTRLMODE_FD 0x20 /* CAN FD mode */
#define CAN_CTRLMODE_PRESUME_ACK 0x40 /* Ignore missing CAN ACKs */
#define CAN_CTRLMODE_FD_NON_ISO 0x80 /* CAN FD in non-ISO mode */
#define CAN_CTRLMODE_CC_LEN8_DLC 0x100 /* Classic CAN DLC option */
/*
* CAN device statistics

View File

@ -94,6 +94,7 @@
#define BOND_XMIT_POLICY_LAYER23 2 /* layer 2+3 (IP ^ MAC) */
#define BOND_XMIT_POLICY_ENCAP23 3 /* encapsulated layer 2+3 */
#define BOND_XMIT_POLICY_ENCAP34 4 /* encapsulated layer 3+4 */
#define BOND_XMIT_POLICY_VLAN_SRCMAC 5 /* vlan + source MAC */
/* 802.3ad port state definitions (43.4.2.2 in the 802.3ad standard) */
#define LACP_STATE_LACP_ACTIVITY 0x1
@ -152,14 +153,3 @@ enum {
#define BOND_3AD_STAT_MAX (__BOND_3AD_STAT_MAX - 1)
#endif /* _LINUX_IF_BONDING_H */
/*
* Local variables:
* version-control: t
* kept-new-versions: 5
* c-indent-level: 8
* c-basic-offset: 8
* tab-width: 8
* End:
*/

View File

@ -121,6 +121,7 @@ enum {
IFLA_BRIDGE_VLAN_INFO,
IFLA_BRIDGE_VLAN_TUNNEL_INFO,
IFLA_BRIDGE_MRP,
IFLA_BRIDGE_CFM,
__IFLA_BRIDGE_MAX,
};
#define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1)
@ -328,6 +329,130 @@ struct br_mrp_start_in_test {
__u16 in_id;
};
enum {
IFLA_BRIDGE_CFM_UNSPEC,
IFLA_BRIDGE_CFM_MEP_CREATE,
IFLA_BRIDGE_CFM_MEP_DELETE,
IFLA_BRIDGE_CFM_MEP_CONFIG,
IFLA_BRIDGE_CFM_CC_CONFIG,
IFLA_BRIDGE_CFM_CC_PEER_MEP_ADD,
IFLA_BRIDGE_CFM_CC_PEER_MEP_REMOVE,
IFLA_BRIDGE_CFM_CC_RDI,
IFLA_BRIDGE_CFM_CC_CCM_TX,
IFLA_BRIDGE_CFM_MEP_CREATE_INFO,
IFLA_BRIDGE_CFM_MEP_CONFIG_INFO,
IFLA_BRIDGE_CFM_CC_CONFIG_INFO,
IFLA_BRIDGE_CFM_CC_RDI_INFO,
IFLA_BRIDGE_CFM_CC_CCM_TX_INFO,
IFLA_BRIDGE_CFM_CC_PEER_MEP_INFO,
IFLA_BRIDGE_CFM_MEP_STATUS_INFO,
IFLA_BRIDGE_CFM_CC_PEER_STATUS_INFO,
__IFLA_BRIDGE_CFM_MAX,
};
#define IFLA_BRIDGE_CFM_MAX (__IFLA_BRIDGE_CFM_MAX - 1)
enum {
IFLA_BRIDGE_CFM_MEP_CREATE_UNSPEC,
IFLA_BRIDGE_CFM_MEP_CREATE_INSTANCE,
IFLA_BRIDGE_CFM_MEP_CREATE_DOMAIN,
IFLA_BRIDGE_CFM_MEP_CREATE_DIRECTION,
IFLA_BRIDGE_CFM_MEP_CREATE_IFINDEX,
__IFLA_BRIDGE_CFM_MEP_CREATE_MAX,
};
#define IFLA_BRIDGE_CFM_MEP_CREATE_MAX (__IFLA_BRIDGE_CFM_MEP_CREATE_MAX - 1)
enum {
IFLA_BRIDGE_CFM_MEP_DELETE_UNSPEC,
IFLA_BRIDGE_CFM_MEP_DELETE_INSTANCE,
__IFLA_BRIDGE_CFM_MEP_DELETE_MAX,
};
#define IFLA_BRIDGE_CFM_MEP_DELETE_MAX (__IFLA_BRIDGE_CFM_MEP_DELETE_MAX - 1)
enum {
IFLA_BRIDGE_CFM_MEP_CONFIG_UNSPEC,
IFLA_BRIDGE_CFM_MEP_CONFIG_INSTANCE,
IFLA_BRIDGE_CFM_MEP_CONFIG_UNICAST_MAC,
IFLA_BRIDGE_CFM_MEP_CONFIG_MDLEVEL,
IFLA_BRIDGE_CFM_MEP_CONFIG_MEPID,
__IFLA_BRIDGE_CFM_MEP_CONFIG_MAX,
};
#define IFLA_BRIDGE_CFM_MEP_CONFIG_MAX (__IFLA_BRIDGE_CFM_MEP_CONFIG_MAX - 1)
enum {
IFLA_BRIDGE_CFM_CC_CONFIG_UNSPEC,
IFLA_BRIDGE_CFM_CC_CONFIG_INSTANCE,
IFLA_BRIDGE_CFM_CC_CONFIG_ENABLE,
IFLA_BRIDGE_CFM_CC_CONFIG_EXP_INTERVAL,
IFLA_BRIDGE_CFM_CC_CONFIG_EXP_MAID,
__IFLA_BRIDGE_CFM_CC_CONFIG_MAX,
};
#define IFLA_BRIDGE_CFM_CC_CONFIG_MAX (__IFLA_BRIDGE_CFM_CC_CONFIG_MAX - 1)
enum {
IFLA_BRIDGE_CFM_CC_PEER_MEP_UNSPEC,
IFLA_BRIDGE_CFM_CC_PEER_MEP_INSTANCE,
IFLA_BRIDGE_CFM_CC_PEER_MEPID,
__IFLA_BRIDGE_CFM_CC_PEER_MEP_MAX,
};
#define IFLA_BRIDGE_CFM_CC_PEER_MEP_MAX (__IFLA_BRIDGE_CFM_CC_PEER_MEP_MAX - 1)
enum {
IFLA_BRIDGE_CFM_CC_RDI_UNSPEC,
IFLA_BRIDGE_CFM_CC_RDI_INSTANCE,
IFLA_BRIDGE_CFM_CC_RDI_RDI,
__IFLA_BRIDGE_CFM_CC_RDI_MAX,
};
#define IFLA_BRIDGE_CFM_CC_RDI_MAX (__IFLA_BRIDGE_CFM_CC_RDI_MAX - 1)
enum {
IFLA_BRIDGE_CFM_CC_CCM_TX_UNSPEC,
IFLA_BRIDGE_CFM_CC_CCM_TX_INSTANCE,
IFLA_BRIDGE_CFM_CC_CCM_TX_DMAC,
IFLA_BRIDGE_CFM_CC_CCM_TX_SEQ_NO_UPDATE,
IFLA_BRIDGE_CFM_CC_CCM_TX_PERIOD,
IFLA_BRIDGE_CFM_CC_CCM_TX_IF_TLV,
IFLA_BRIDGE_CFM_CC_CCM_TX_IF_TLV_VALUE,
IFLA_BRIDGE_CFM_CC_CCM_TX_PORT_TLV,
IFLA_BRIDGE_CFM_CC_CCM_TX_PORT_TLV_VALUE,
__IFLA_BRIDGE_CFM_CC_CCM_TX_MAX,
};
#define IFLA_BRIDGE_CFM_CC_CCM_TX_MAX (__IFLA_BRIDGE_CFM_CC_CCM_TX_MAX - 1)
enum {
IFLA_BRIDGE_CFM_MEP_STATUS_UNSPEC,
IFLA_BRIDGE_CFM_MEP_STATUS_INSTANCE,
IFLA_BRIDGE_CFM_MEP_STATUS_OPCODE_UNEXP_SEEN,
IFLA_BRIDGE_CFM_MEP_STATUS_VERSION_UNEXP_SEEN,
IFLA_BRIDGE_CFM_MEP_STATUS_RX_LEVEL_LOW_SEEN,
__IFLA_BRIDGE_CFM_MEP_STATUS_MAX,
};
#define IFLA_BRIDGE_CFM_MEP_STATUS_MAX (__IFLA_BRIDGE_CFM_MEP_STATUS_MAX - 1)
enum {
IFLA_BRIDGE_CFM_CC_PEER_STATUS_UNSPEC,
IFLA_BRIDGE_CFM_CC_PEER_STATUS_INSTANCE,
IFLA_BRIDGE_CFM_CC_PEER_STATUS_PEER_MEPID,
IFLA_BRIDGE_CFM_CC_PEER_STATUS_CCM_DEFECT,
IFLA_BRIDGE_CFM_CC_PEER_STATUS_RDI,
IFLA_BRIDGE_CFM_CC_PEER_STATUS_PORT_TLV_VALUE,
IFLA_BRIDGE_CFM_CC_PEER_STATUS_IF_TLV_VALUE,
IFLA_BRIDGE_CFM_CC_PEER_STATUS_SEEN,
IFLA_BRIDGE_CFM_CC_PEER_STATUS_TLV_SEEN,
IFLA_BRIDGE_CFM_CC_PEER_STATUS_SEQ_UNEXP_SEEN,
__IFLA_BRIDGE_CFM_CC_PEER_STATUS_MAX,
};
#define IFLA_BRIDGE_CFM_CC_PEER_STATUS_MAX (__IFLA_BRIDGE_CFM_CC_PEER_STATUS_MAX - 1)
struct bridge_stp_xstats {
__u64 transition_blk;
__u64 transition_fwd;
@ -502,6 +627,8 @@ enum {
MDBA_ROUTER_PATTR_UNSPEC,
MDBA_ROUTER_PATTR_TIMER,
MDBA_ROUTER_PATTR_TYPE,
MDBA_ROUTER_PATTR_INET_TIMER,
MDBA_ROUTER_PATTR_INET6_TIMER,
__MDBA_ROUTER_PATTR_MAX
};
#define MDBA_ROUTER_PATTR_MAX (__MDBA_ROUTER_PATTR_MAX - 1)
@ -526,6 +653,7 @@ struct br_mdb_entry {
union {
__be32 ip4;
struct in6_addr ip6;
unsigned char mac_addr[ETH_ALEN];
} u;
__be16 proto;
} addr;

View File

@ -99,6 +99,7 @@
#define ETH_P_1588 0x88F7 /* IEEE 1588 Timesync */
#define ETH_P_NCSI 0x88F8 /* NCSI protocol */
#define ETH_P_PRP 0x88FB /* IEC 62439-3 PRP/HSRv0 */
#define ETH_P_CFM 0x8902 /* Connectivity Fault Management */
#define ETH_P_FCOE 0x8906 /* Fibre Channel over Ethernet */
#define ETH_P_IBOE 0x8915 /* Infiniband over Ethernet */
#define ETH_P_TDLS 0x890D /* TDLS */

View File

@ -341,6 +341,13 @@ enum {
IFLA_ALT_IFNAME, /* Alternative ifname */
IFLA_PERM_ADDRESS,
IFLA_PROTO_DOWN_REASON,
/* device (sysfs) name as parent, used instead
* of IFLA_LINK where there's no parent netdev
*/
IFLA_PARENT_DEV_NAME,
IFLA_PARENT_DEV_BUS_NAME,
__IFLA_MAX
};
@ -525,6 +532,8 @@ enum {
IFLA_BRPORT_BACKUP_PORT,
IFLA_BRPORT_MRP_RING_OPEN,
IFLA_BRPORT_MRP_IN_OPEN,
IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT,
IFLA_BRPORT_MCAST_EHT_HOSTS_CNT,
__IFLA_BRPORT_MAX
};
#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
@ -612,6 +621,7 @@ enum macvlan_macaddr_mode {
};
#define MACVLAN_FLAG_NOPROMISC 1
#define MACVLAN_FLAG_NODST 2 /* skip dst macvlan if matching src macvlan */
/* VRF section */
enum {
@ -1233,6 +1243,8 @@ enum {
#define RMNET_FLAGS_INGRESS_MAP_COMMANDS (1U << 1)
#define RMNET_FLAGS_INGRESS_MAP_CKSUMV4 (1U << 2)
#define RMNET_FLAGS_EGRESS_MAP_CKSUMV4 (1U << 3)
#define RMNET_FLAGS_INGRESS_MAP_CKSUMV5 (1U << 4)
#define RMNET_FLAGS_EGRESS_MAP_CKSUMV5 (1U << 5)
enum {
IFLA_RMNET_UNSPEC,

View File

@ -289,6 +289,9 @@ struct sockaddr_in {
/* Address indicating an error return. */
#define INADDR_NONE ((unsigned long int) 0xffffffff)
/* Dummy address for src of ICMP replies if no real address is set (RFC7600). */
#define INADDR_DUMMY ((unsigned long int) 0xc0000008)
/* Network number for local host loopback. */
#define IN_LOOPBACKNET 127

View File

@ -145,6 +145,7 @@ enum {
L2TP_ATTR_RX_ERRORS, /* u64 */
L2TP_ATTR_STATS_PAD,
L2TP_ATTR_RX_COOKIE_DISCARDS, /* u64 */
L2TP_ATTR_RX_INVALID, /* u64 */
__L2TP_ATTR_STATS_MAX,
};

View File

@ -133,7 +133,7 @@ enum nf_tables_msg_types {
* @NFTA_LIST_ELEM: list element (NLA_NESTED)
*/
enum nft_list_attributes {
NFTA_LIST_UNPEC,
NFTA_LIST_UNSPEC,
NFTA_LIST_ELEM,
__NFTA_LIST_MAX
};
@ -164,7 +164,10 @@ enum nft_hook_attributes {
*/
enum nft_table_flags {
NFT_TABLE_F_DORMANT = 0x1,
NFT_TABLE_F_OWNER = 0x2,
};
#define NFT_TABLE_F_MASK (NFT_TABLE_F_DORMANT | \
NFT_TABLE_F_OWNER)
/**
* enum nft_table_attributes - nf_tables table netlink attributes
@ -172,6 +175,8 @@ enum nft_table_flags {
* @NFTA_TABLE_NAME: name of the table (NLA_STRING)
* @NFTA_TABLE_FLAGS: bitmask of enum nft_table_flags (NLA_U32)
* @NFTA_TABLE_USE: number of chains in this table (NLA_U32)
* @NFTA_TABLE_USERDATA: user data (NLA_BINARY)
* @NFTA_TABLE_OWNER: owner of this table through netlink portID (NLA_U32)
*/
enum nft_table_attributes {
NFTA_TABLE_UNSPEC,
@ -180,10 +185,21 @@ enum nft_table_attributes {
NFTA_TABLE_USE,
NFTA_TABLE_HANDLE,
NFTA_TABLE_PAD,
NFTA_TABLE_USERDATA,
NFTA_TABLE_OWNER,
__NFTA_TABLE_MAX
};
#define NFTA_TABLE_MAX (__NFTA_TABLE_MAX - 1)
enum nft_chain_flags {
NFT_CHAIN_BASE = (1 << 0),
NFT_CHAIN_HW_OFFLOAD = (1 << 1),
NFT_CHAIN_BINDING = (1 << 2),
};
#define NFT_CHAIN_FLAGS (NFT_CHAIN_BASE | \
NFT_CHAIN_HW_OFFLOAD | \
NFT_CHAIN_BINDING)
/**
* enum nft_chain_attributes - nf_tables chain netlink attributes
*
@ -196,6 +212,8 @@ enum nft_table_attributes {
* @NFTA_CHAIN_TYPE: type name of the string (NLA_NUL_STRING)
* @NFTA_CHAIN_COUNTERS: counter specification of the chain (NLA_NESTED: nft_counter_attributes)
* @NFTA_CHAIN_FLAGS: chain flags
* @NFTA_CHAIN_ID: uniquely identifies a chain in a transaction (NLA_U32)
* @NFTA_CHAIN_USERDATA: user data (NLA_BINARY)
*/
enum nft_chain_attributes {
NFTA_CHAIN_UNSPEC,
@ -209,6 +227,8 @@ enum nft_chain_attributes {
NFTA_CHAIN_COUNTERS,
NFTA_CHAIN_PAD,
NFTA_CHAIN_FLAGS,
NFTA_CHAIN_ID,
NFTA_CHAIN_USERDATA,
__NFTA_CHAIN_MAX
};
#define NFTA_CHAIN_MAX (__NFTA_CHAIN_MAX - 1)
@ -238,6 +258,7 @@ enum nft_rule_attributes {
NFTA_RULE_PAD,
NFTA_RULE_ID,
NFTA_RULE_POSITION_ID,
NFTA_RULE_CHAIN_ID,
__NFTA_RULE_MAX
};
#define NFTA_RULE_MAX (__NFTA_RULE_MAX - 1)
@ -277,6 +298,7 @@ enum nft_rule_compat_attributes {
* @NFT_SET_EVAL: set can be updated from the evaluation path
* @NFT_SET_OBJECT: set contains stateful objects
* @NFT_SET_CONCAT: set contains a concatenation
* @NFT_SET_EXPR: set contains expressions
*/
enum nft_set_flags {
NFT_SET_ANONYMOUS = 0x1,
@ -287,6 +309,7 @@ enum nft_set_flags {
NFT_SET_EVAL = 0x20,
NFT_SET_OBJECT = 0x40,
NFT_SET_CONCAT = 0x80,
NFT_SET_EXPR = 0x100,
};
/**
@ -345,6 +368,7 @@ enum nft_set_field_attributes {
* @NFTA_SET_OBJ_TYPE: stateful object type (NLA_U32: NFT_OBJECT_*)
* @NFTA_SET_HANDLE: set handle (NLA_U64)
* @NFTA_SET_EXPR: set expression (NLA_NESTED: nft_expr_attributes)
* @NFTA_SET_EXPRESSIONS: list of expressions (NLA_NESTED: nft_list_attributes)
*/
enum nft_set_attributes {
NFTA_SET_UNSPEC,
@ -365,6 +389,7 @@ enum nft_set_attributes {
NFTA_SET_OBJ_TYPE,
NFTA_SET_HANDLE,
NFTA_SET_EXPR,
NFTA_SET_EXPRESSIONS,
__NFTA_SET_MAX
};
#define NFTA_SET_MAX (__NFTA_SET_MAX - 1)
@ -373,9 +398,11 @@ enum nft_set_attributes {
* enum nft_set_elem_flags - nf_tables set element flags
*
* @NFT_SET_ELEM_INTERVAL_END: element ends the previous interval
* @NFT_SET_ELEM_CATCHALL: special catch-all element
*/
enum nft_set_elem_flags {
NFT_SET_ELEM_INTERVAL_END = 0x1,
NFT_SET_ELEM_CATCHALL = 0x2,
};
/**
@ -390,6 +417,7 @@ enum nft_set_elem_flags {
* @NFTA_SET_ELEM_EXPR: expression (NLA_NESTED: nft_expr_attributes)
* @NFTA_SET_ELEM_OBJREF: stateful object reference (NLA_STRING)
* @NFTA_SET_ELEM_KEY_END: closing key value (NLA_NESTED: nft_data)
* @NFTA_SET_ELEM_EXPRESSIONS: list of expressions (NLA_NESTED: nft_list_attributes)
*/
enum nft_set_elem_attributes {
NFTA_SET_ELEM_UNSPEC,
@ -403,6 +431,7 @@ enum nft_set_elem_attributes {
NFTA_SET_ELEM_PAD,
NFTA_SET_ELEM_OBJREF,
NFTA_SET_ELEM_KEY_END,
NFTA_SET_ELEM_EXPRESSIONS,
__NFTA_SET_ELEM_MAX
};
#define NFTA_SET_ELEM_MAX (__NFTA_SET_ELEM_MAX - 1)
@ -468,11 +497,13 @@ enum nft_data_attributes {
*
* @NFTA_VERDICT_CODE: nf_tables verdict (NLA_U32: enum nft_verdicts)
* @NFTA_VERDICT_CHAIN: jump target chain name (NLA_STRING)
* @NFTA_VERDICT_CHAIN_ID: jump target chain ID (NLA_U32)
*/
enum nft_verdict_attributes {
NFTA_VERDICT_UNSPEC,
NFTA_VERDICT_CODE,
NFTA_VERDICT_CHAIN,
NFTA_VERDICT_CHAIN_ID,
__NFTA_VERDICT_MAX
};
#define NFTA_VERDICT_MAX (__NFTA_VERDICT_MAX - 1)
@ -684,6 +715,7 @@ enum nft_dynset_ops {
enum nft_dynset_flags {
NFT_DYNSET_F_INV = (1 << 0),
NFT_DYNSET_F_EXPR = (1 << 1),
};
/**
@ -697,6 +729,7 @@ enum nft_dynset_flags {
* @NFTA_DYNSET_TIMEOUT: timeout value for the new element (NLA_U64)
* @NFTA_DYNSET_EXPR: expression (NLA_NESTED: nft_expr_attributes)
* @NFTA_DYNSET_FLAGS: flags (NLA_U32)
* @NFTA_DYNSET_EXPRESSIONS: list of expressions (NLA_NESTED: nft_list_attributes)
*/
enum nft_dynset_attributes {
NFTA_DYNSET_UNSPEC,
@ -709,6 +742,7 @@ enum nft_dynset_attributes {
NFTA_DYNSET_EXPR,
NFTA_DYNSET_PAD,
NFTA_DYNSET_FLAGS,
NFTA_DYNSET_EXPRESSIONS,
__NFTA_DYNSET_MAX,
};
#define NFTA_DYNSET_MAX (__NFTA_DYNSET_MAX - 1)
@ -731,10 +765,12 @@ enum nft_payload_bases {
*
* @NFT_PAYLOAD_CSUM_NONE: no checksumming
* @NFT_PAYLOAD_CSUM_INET: internet checksum (RFC 791)
* @NFT_PAYLOAD_CSUM_SCTP: CRC-32c, for use in SCTP header (RFC 3309)
*/
enum nft_payload_csum_types {
NFT_PAYLOAD_CSUM_NONE,
NFT_PAYLOAD_CSUM_INET,
NFT_PAYLOAD_CSUM_SCTP,
};
enum nft_payload_csum_flags {
@ -777,11 +813,13 @@ enum nft_exthdr_flags {
* @NFT_EXTHDR_OP_IPV6: match against ipv6 extension headers
* @NFT_EXTHDR_OP_TCP: match against tcp options
* @NFT_EXTHDR_OP_IPV4: match against ipv4 options
* @NFT_EXTHDR_OP_SCTP: match against sctp chunks
*/
enum nft_exthdr_op {
NFT_EXTHDR_OP_IPV6,
NFT_EXTHDR_OP_TCPOPT,
NFT_EXTHDR_OP_IPV4,
NFT_EXTHDR_OP_SCTP,
__NFT_EXTHDR_OP_MAX
};
#define NFT_EXTHDR_OP_MAX (__NFT_EXTHDR_OP_MAX - 1)
@ -980,11 +1018,13 @@ enum nft_rt_attributes {
*
* @NFTA_SOCKET_KEY: socket key to match
* @NFTA_SOCKET_DREG: destination register
* @NFTA_SOCKET_LEVEL: cgroups2 ancestor level (only for cgroupsv2)
*/
enum nft_socket_attributes {
NFTA_SOCKET_UNSPEC,
NFTA_SOCKET_KEY,
NFTA_SOCKET_DREG,
NFTA_SOCKET_LEVEL,
__NFTA_SOCKET_MAX
};
#define NFTA_SOCKET_MAX (__NFTA_SOCKET_MAX - 1)
@ -994,10 +1034,14 @@ enum nft_socket_attributes {
*
* @NFT_SOCKET_TRANSPARENT: Value of the IP(V6)_TRANSPARENT socket option
* @NFT_SOCKET_MARK: Value of the socket mark
* @NFT_SOCKET_WILDCARD: Whether the socket is zero-bound (e.g. 0.0.0.0 or ::0)
* @NFT_SOCKET_CGROUPV2: Match on cgroups version 2
*/
enum nft_socket_keys {
NFT_SOCKET_TRANSPARENT,
NFT_SOCKET_MARK,
NFT_SOCKET_WILDCARD,
NFT_SOCKET_CGROUPV2,
__NFT_SOCKET_MAX
};
#define NFT_SOCKET_MAX (__NFT_SOCKET_MAX - 1)
@ -1151,6 +1195,21 @@ enum nft_counter_attributes {
};
#define NFTA_COUNTER_MAX (__NFTA_COUNTER_MAX - 1)
/**
* enum nft_last_attributes - nf_tables last expression netlink attributes
*
* @NFTA_LAST_SET: last update has been set, zero means never updated (NLA_U32)
* @NFTA_LAST_MSECS: milliseconds since last update (NLA_U64)
*/
enum nft_last_attributes {
NFTA_LAST_UNSPEC,
NFTA_LAST_SET,
NFTA_LAST_MSECS,
NFTA_LAST_PAD,
__NFTA_LAST_MAX
};
#define NFTA_LAST_MAX (__NFTA_LAST_MAX - 1)
/**
* enum nft_log_attributes - nf_tables log expression netlink attributes
*
@ -1541,6 +1600,7 @@ enum nft_ct_expectation_attributes {
* @NFTA_OBJ_DATA: stateful object data (NLA_NESTED)
* @NFTA_OBJ_USE: number of references to this expression (NLA_U32)
* @NFTA_OBJ_HANDLE: object handle (NLA_U64)
* @NFTA_OBJ_USERDATA: user data (NLA_BINARY)
*/
enum nft_object_attributes {
NFTA_OBJ_UNSPEC,
@ -1551,6 +1611,7 @@ enum nft_object_attributes {
NFTA_OBJ_USE,
NFTA_OBJ_HANDLE,
NFTA_OBJ_PAD,
NFTA_OBJ_USERDATA,
__NFTA_OBJ_MAX
};
#define NFTA_OBJ_MAX (__NFTA_OBJ_MAX - 1)

View File

@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#ifndef _NFNETLINK_H
#define _NFNETLINK_H
#ifndef _UAPI_NFNETLINK_H
#define _UAPI_NFNETLINK_H
#include <linux/types.h>
#include <linux/netfilter/nfnetlink_compat.h>
@ -60,7 +60,8 @@ struct nfgenmsg {
#define NFNL_SUBSYS_CTHELPER 9
#define NFNL_SUBSYS_NFTABLES 10
#define NFNL_SUBSYS_NFT_COMPAT 11
#define NFNL_SUBSYS_COUNT 12
#define NFNL_SUBSYS_HOOK 12
#define NFNL_SUBSYS_COUNT 13
/* Reserved control nfnetlink messages */
#define NFNL_MSG_BATCH_BEGIN NLMSG_MIN_TYPE
@ -78,4 +79,4 @@ enum nfnl_batch_attributes {
};
#define NFNL_BATCH_MAX (__NFNL_BATCH_MAX - 1)
#endif /* _NFNETLINK_H */
#endif /* _UAPI_NFNETLINK_H */

View File

@ -2,7 +2,7 @@
#ifndef _UAPI__LINUX_NETLINK_H
#define _UAPI__LINUX_NETLINK_H
#include <linux/kernel.h>
#include <linux/const.h>
#include <linux/socket.h> /* for __kernel_sa_family_t */
#include <linux/types.h>
@ -91,9 +91,10 @@ struct nlmsghdr {
#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
#define NLMSG_LENGTH(len) ((len) + NLMSG_HDRLEN)
#define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))
#define NLMSG_DATA(nlh) ((void*)(((char*)nlh) + NLMSG_LENGTH(0)))
#define NLMSG_DATA(nlh) ((void *)(((char *)nlh) + NLMSG_HDRLEN))
#define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \
(struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)))
(struct nlmsghdr *)(((char *)(nlh)) + \
NLMSG_ALIGN((nlh)->nlmsg_len)))
#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \
(nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
(nlh)->nlmsg_len <= (len))

View File

@ -21,7 +21,10 @@ struct nexthop_grp {
};
enum {
NEXTHOP_GRP_TYPE_MPATH, /* default type if not specified */
NEXTHOP_GRP_TYPE_MPATH, /* hash-threshold nexthop group
* default type if not specified
*/
NEXTHOP_GRP_TYPE_RES, /* resilient nexthop group */
__NEXTHOP_GRP_TYPE_MAX,
};
@ -52,8 +55,50 @@ enum {
NHA_FDB, /* flag; nexthop belongs to a bridge fdb */
/* if NHA_FDB is added, OIF, BLACKHOLE, ENCAP cannot be set */
/* nested; resilient nexthop group attributes */
NHA_RES_GROUP,
/* nested; nexthop bucket attributes */
NHA_RES_BUCKET,
__NHA_MAX,
};
#define NHA_MAX (__NHA_MAX - 1)
enum {
NHA_RES_GROUP_UNSPEC,
/* Pad attribute for 64-bit alignment. */
NHA_RES_GROUP_PAD = NHA_RES_GROUP_UNSPEC,
/* u16; number of nexthop buckets in a resilient nexthop group */
NHA_RES_GROUP_BUCKETS,
/* clock_t as u32; nexthop bucket idle timer (per-group) */
NHA_RES_GROUP_IDLE_TIMER,
/* clock_t as u32; nexthop unbalanced timer */
NHA_RES_GROUP_UNBALANCED_TIMER,
/* clock_t as u64; nexthop unbalanced time */
NHA_RES_GROUP_UNBALANCED_TIME,
__NHA_RES_GROUP_MAX,
};
#define NHA_RES_GROUP_MAX (__NHA_RES_GROUP_MAX - 1)
enum {
NHA_RES_BUCKET_UNSPEC,
/* Pad attribute for 64-bit alignment. */
NHA_RES_BUCKET_PAD = NHA_RES_BUCKET_UNSPEC,
/* u16; nexthop bucket index */
NHA_RES_BUCKET_INDEX,
/* clock_t as u64; nexthop bucket idle time */
NHA_RES_BUCKET_IDLE_TIME,
/* u32; nexthop id assigned to the nexthop bucket */
NHA_RES_BUCKET_NH_ID,
__NHA_RES_BUCKET_MAX,
};
#define NHA_RES_BUCKET_MAX (__NHA_RES_BUCKET_MAX - 1)
#endif

View File

@ -11,7 +11,7 @@
* Copyright 2008 Jouni Malinen <jouni.malinen@atheros.com>
* Copyright 2008 Colin McCabe <colin@cozybit.com>
* Copyright 2015-2017 Intel Deutschland GmbH
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@ -655,6 +655,9 @@
* When a security association was established on an 802.1X network using
* fast transition, this event should be followed by an
* %NL80211_CMD_PORT_AUTHORIZED event.
* Following a %NL80211_CMD_ROAM event userspace can issue
* %NL80211_CMD_GET_SCAN in order to obtain the scan information for the
* new BSS the card/driver roamed to.
* @NL80211_CMD_DISCONNECT: drop a given connection; also used to notify
* userspace that a connection was dropped by the AP or due to other
* reasons, for this the %NL80211_ATTR_DISCONNECTED_BY_AP and
@ -757,7 +760,8 @@
* of any other interfaces, and other interfaces will again take
* precedence when they are used.
*
* @NL80211_CMD_SET_WDS_PEER: Set the MAC address of the peer on a WDS interface.
* @NL80211_CMD_SET_WDS_PEER: Set the MAC address of the peer on a WDS interface
* (no longer supported).
*
* @NL80211_CMD_SET_MULTICAST_TO_UNICAST: Configure if this AP should perform
* multicast to unicast conversion. When enabled, all multicast packets
@ -1177,6 +1181,10 @@
* includes the contents of the frame. %NL80211_ATTR_ACK flag is included
* if the recipient acknowledged the frame.
*
* @NL80211_CMD_SET_SAR_SPECS: SAR power limitation configuration is
* passed using %NL80211_ATTR_SAR_SPEC. %NL80211_ATTR_WIPHY is used to
* specify the wiphy index to be applied to.
*
* @NL80211_CMD_MAX: highest used command number
* @__NL80211_CMD_AFTER_LAST: internal use
*/
@ -1407,6 +1415,8 @@ enum nl80211_commands {
NL80211_CMD_CONTROL_PORT_FRAME_TX_STATUS,
NL80211_CMD_SET_SAR_SPECS,
/* add new commands above here */
/* used to define NL80211_CMD_MAX below */
@ -1750,8 +1760,9 @@ enum nl80211_commands {
* specify just a single bitrate, which is to be used for the beacon.
* The driver must also specify support for this with the extended
* features NL80211_EXT_FEATURE_BEACON_RATE_LEGACY,
* NL80211_EXT_FEATURE_BEACON_RATE_HT and
* NL80211_EXT_FEATURE_BEACON_RATE_VHT.
* NL80211_EXT_FEATURE_BEACON_RATE_HT,
* NL80211_EXT_FEATURE_BEACON_RATE_VHT and
* NL80211_EXT_FEATURE_BEACON_RATE_HE.
*
* @NL80211_ATTR_FRAME_MATCH: A binary attribute which typically must contain
* at least one byte, currently used with @NL80211_CMD_REGISTER_FRAME.
@ -1955,8 +1966,15 @@ enum nl80211_commands {
* @NL80211_ATTR_PROBE_RESP: Probe Response template data. Contains the entire
* probe-response frame. The DA field in the 802.11 header is zero-ed out,
* to be filled by the FW.
* @NL80211_ATTR_DISABLE_HT: Force HT capable interfaces to disable
* this feature. Currently, only supported in mac80211 drivers.
* @NL80211_ATTR_DISABLE_HT: Force HT capable interfaces to disable
* this feature during association. This is a flag attribute.
* Currently only supported in mac80211 drivers.
* @NL80211_ATTR_DISABLE_VHT: Force VHT capable interfaces to disable
* this feature during association. This is a flag attribute.
* Currently only supported in mac80211 drivers.
* @NL80211_ATTR_DISABLE_HE: Force HE capable interfaces to disable
* this feature during association. This is a flag attribute.
* Currently only supported in mac80211 drivers.
* @NL80211_ATTR_HT_CAPABILITY_MASK: Specify which bits of the
* ATTR_HT_CAPABILITY to which attention should be paid.
* Currently, only mac80211 NICs support this feature.
@ -2077,7 +2095,8 @@ enum nl80211_commands {
* until the channel switch event.
* @NL80211_ATTR_CH_SWITCH_BLOCK_TX: flag attribute specifying that transmission
* must be blocked on the current channel (before the channel switch
* operation).
* operation). Also included in the channel switch started event if quiet
* was requested by the AP.
* @NL80211_ATTR_CSA_IES: Nested set of attributes containing the IE information
* for the time while performing a channel switch.
* @NL80211_ATTR_CNTDWN_OFFS_BEACON: An array of offsets (u16) to the channel
@ -2527,6 +2546,20 @@ enum nl80211_commands {
* override mask. Used with NL80211_ATTR_S1G_CAPABILITY in
* NL80211_CMD_ASSOCIATE or NL80211_CMD_CONNECT.
*
* @NL80211_ATTR_SAE_PWE: Indicates the mechanism(s) allowed for SAE PWE
* derivation in WPA3-Personal networks which are using SAE authentication.
* This is a u8 attribute that encapsulates one of the values from
* &enum nl80211_sae_pwe_mechanism.
*
* @NL80211_ATTR_SAR_SPEC: SAR power limitation specification when
* used with %NL80211_CMD_SET_SAR_SPECS. The message contains fields
* of %nl80211_sar_attrs which specifies the sar type and related
* sar specs. Sar specs contains array of %nl80211_sar_specs_attrs.
*
* @NL80211_ATTR_RECONNECT_REQUESTED: flag attribute, used with deauth and
* disassoc events to indicate that an immediate reconnect to the AP
* is desired.
*
* @NUM_NL80211_ATTR: total number of nl80211_attrs available
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
@ -3016,6 +3049,14 @@ enum nl80211_attrs {
NL80211_ATTR_S1G_CAPABILITY,
NL80211_ATTR_S1G_CAPABILITY_MASK,
NL80211_ATTR_SAE_PWE,
NL80211_ATTR_RECONNECT_REQUESTED,
NL80211_ATTR_SAR_SPEC,
NL80211_ATTR_DISABLE_HE,
/* add attributes here, update the policy in nl80211.c */
__NL80211_ATTR_AFTER_LAST,
@ -3613,6 +3654,8 @@ enum nl80211_mpath_info {
* defined
* @NL80211_BAND_IFTYPE_ATTR_HE_6GHZ_CAPA: HE 6GHz band capabilities (__le16),
* given for all 6 GHz band channels
* @NL80211_BAND_IFTYPE_ATTR_VENDOR_ELEMS: vendor element capabilities that are
* advertised on this band/for this iftype (binary)
* @__NL80211_BAND_IFTYPE_ATTR_AFTER_LAST: internal use
*/
enum nl80211_band_iftype_attr {
@ -3624,6 +3667,7 @@ enum nl80211_band_iftype_attr {
NL80211_BAND_IFTYPE_ATTR_HE_CAP_MCS_SET,
NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE,
NL80211_BAND_IFTYPE_ATTR_HE_6GHZ_CAPA,
NL80211_BAND_IFTYPE_ATTR_VENDOR_ELEMS,
/* keep last */
__NL80211_BAND_IFTYPE_ATTR_AFTER_LAST,
@ -5896,6 +5940,19 @@ enum nl80211_feature_flags {
* @NL80211_EXT_FEATURE_UNSOL_BCAST_PROBE_RESP: Driver/device supports
* unsolicited broadcast probe response transmission
*
* @NL80211_EXT_FEATURE_BEACON_RATE_HE: Driver supports beacon rate
* configuration (AP/mesh) with HE rates.
*
* @NL80211_EXT_FEATURE_SECURE_LTF: Device supports secure LTF measurement
* exchange protocol.
*
* @NL80211_EXT_FEATURE_SECURE_RTT: Device supports secure RTT measurement
* exchange protocol.
*
* @NL80211_EXT_FEATURE_PROT_RANGE_NEGO_AND_MEASURE: Device supports management
* frame protection for all management frames exchanged during the
* negotiation and range measurement procedure.
*
* @NUM_NL80211_EXT_FEATURES: number of extended features.
* @MAX_NL80211_EXT_FEATURES: highest extended feature index.
*/
@ -5956,6 +6013,10 @@ enum nl80211_ext_feature_index {
NL80211_EXT_FEATURE_SAE_OFFLOAD_AP,
NL80211_EXT_FEATURE_FILS_DISCOVERY,
NL80211_EXT_FEATURE_UNSOL_BCAST_PROBE_RESP,
NL80211_EXT_FEATURE_BEACON_RATE_HE,
NL80211_EXT_FEATURE_SECURE_LTF,
NL80211_EXT_FEATURE_SECURE_RTT,
NL80211_EXT_FEATURE_PROT_RANGE_NEGO_AND_MEASURE,
/* add new features before the definition below */
NUM_NL80211_EXT_FEATURES,
@ -6253,11 +6314,13 @@ struct nl80211_vendor_cmd_info {
* @NL80211_TDLS_PEER_HT: TDLS peer is HT capable.
* @NL80211_TDLS_PEER_VHT: TDLS peer is VHT capable.
* @NL80211_TDLS_PEER_WMM: TDLS peer is WMM capable.
* @NL80211_TDLS_PEER_HE: TDLS peer is HE capable.
*/
enum nl80211_tdls_peer_capability {
NL80211_TDLS_PEER_HT = 1<<0,
NL80211_TDLS_PEER_VHT = 1<<1,
NL80211_TDLS_PEER_WMM = 1<<2,
NL80211_TDLS_PEER_HE = 1<<3,
};
/**
@ -6849,6 +6912,12 @@ enum nl80211_peer_measurement_ftm_capa {
* if neither %NL80211_PMSR_FTM_REQ_ATTR_TRIGGER_BASED nor
* %NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED is set, EDCA based
* ranging will be used.
* @NL80211_PMSR_FTM_REQ_ATTR_LMR_FEEDBACK: negotiate for LMR feedback. Only
* valid if either %NL80211_PMSR_FTM_REQ_ATTR_TRIGGER_BASED or
* %NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED is set.
* @NL80211_PMSR_FTM_REQ_ATTR_BSS_COLOR: optional. The BSS color of the
* responder. Only valid if %NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED
* or %NL80211_PMSR_FTM_REQ_ATTR_TRIGGER_BASED is set.
*
* @NUM_NL80211_PMSR_FTM_REQ_ATTR: internal
* @NL80211_PMSR_FTM_REQ_ATTR_MAX: highest attribute number
@ -6867,6 +6936,8 @@ enum nl80211_peer_measurement_ftm_req {
NL80211_PMSR_FTM_REQ_ATTR_REQUEST_CIVICLOC,
NL80211_PMSR_FTM_REQ_ATTR_TRIGGER_BASED,
NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED,
NL80211_PMSR_FTM_REQ_ATTR_LMR_FEEDBACK,
NL80211_PMSR_FTM_REQ_ATTR_BSS_COLOR,
/* keep last */
NUM_NL80211_PMSR_FTM_REQ_ATTR,
@ -7124,4 +7195,115 @@ enum nl80211_unsol_bcast_probe_resp_attributes {
NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_MAX =
__NL80211_UNSOL_BCAST_PROBE_RESP_ATTR_LAST - 1
};
/**
* enum nl80211_sae_pwe_mechanism - The mechanism(s) allowed for SAE PWE
* derivation. Applicable only when WPA3-Personal SAE authentication is
* used.
*
* @NL80211_SAE_PWE_UNSPECIFIED: not specified, used internally to indicate that
* attribute is not present from userspace.
* @NL80211_SAE_PWE_HUNT_AND_PECK: hunting-and-pecking loop only
* @NL80211_SAE_PWE_HASH_TO_ELEMENT: hash-to-element only
* @NL80211_SAE_PWE_BOTH: both hunting-and-pecking loop and hash-to-element
* can be used.
*/
enum nl80211_sae_pwe_mechanism {
NL80211_SAE_PWE_UNSPECIFIED,
NL80211_SAE_PWE_HUNT_AND_PECK,
NL80211_SAE_PWE_HASH_TO_ELEMENT,
NL80211_SAE_PWE_BOTH,
};
/**
* enum nl80211_sar_type - type of SAR specs
*
* @NL80211_SAR_TYPE_POWER: power limitation specified in 0.25dBm unit
*
*/
enum nl80211_sar_type {
NL80211_SAR_TYPE_POWER,
/* add new type here */
/* Keep last */
NUM_NL80211_SAR_TYPE,
};
/**
* enum nl80211_sar_attrs - Attributes for SAR spec
*
* @NL80211_SAR_ATTR_TYPE: the SAR type as defined in &enum nl80211_sar_type.
*
* @NL80211_SAR_ATTR_SPECS: Nested array of SAR power
* limit specifications. Each specification contains a set
* of %nl80211_sar_specs_attrs.
*
* For SET operation, it contains array of %NL80211_SAR_ATTR_SPECS_POWER
* and %NL80211_SAR_ATTR_SPECS_RANGE_INDEX.
*
* For sar_capa dump, it contains array of
* %NL80211_SAR_ATTR_SPECS_START_FREQ
* and %NL80211_SAR_ATTR_SPECS_END_FREQ.
*
* @__NL80211_SAR_ATTR_LAST: Internal
* @NL80211_SAR_ATTR_MAX: highest sar attribute
*
* These attributes are used with %NL80211_CMD_SET_SAR_SPEC
*/
enum nl80211_sar_attrs {
__NL80211_SAR_ATTR_INVALID,
NL80211_SAR_ATTR_TYPE,
NL80211_SAR_ATTR_SPECS,
__NL80211_SAR_ATTR_LAST,
NL80211_SAR_ATTR_MAX = __NL80211_SAR_ATTR_LAST - 1,
};
/**
* enum nl80211_sar_specs_attrs - Attributes for SAR power limit specs
*
* @NL80211_SAR_ATTR_SPECS_POWER: Required (s32)value to specify the actual
* power limit value in units of 0.25 dBm if type is
* NL80211_SAR_TYPE_POWER. (i.e., a value of 44 represents 11 dBm).
* 0 means userspace doesn't have SAR limitation on this associated range.
*
* @NL80211_SAR_ATTR_SPECS_RANGE_INDEX: Required (u32) value to specify the
* index of exported freq range table and the associated power limitation
* is applied to this range.
*
* Userspace isn't required to set all the ranges advertised by WLAN driver,
* and userspace can skip some certain ranges. These skipped ranges don't
* have SAR limitations, and they are same as setting the
* %NL80211_SAR_ATTR_SPECS_POWER to any unreasonable high value because any
* value higher than regulatory allowed value just means SAR power
* limitation is removed, but it's required to set at least one range.
* It's not allowed to set duplicated range in one SET operation.
*
* Every SET operation overwrites previous SET operation.
*
* @NL80211_SAR_ATTR_SPECS_START_FREQ: Required (u32) value to specify the start
* frequency of this range edge when registering SAR capability to wiphy.
* It's not a channel center frequency. The unit is kHz.
*
* @NL80211_SAR_ATTR_SPECS_END_FREQ: Required (u32) value to specify the end
* frequency of this range edge when registering SAR capability to wiphy.
* It's not a channel center frequency. The unit is kHz.
*
* @__NL80211_SAR_ATTR_SPECS_LAST: Internal
* @NL80211_SAR_ATTR_SPECS_MAX: highest sar specs attribute
*/
enum nl80211_sar_specs_attrs {
__NL80211_SAR_ATTR_SPECS_INVALID,
NL80211_SAR_ATTR_SPECS_POWER,
NL80211_SAR_ATTR_SPECS_RANGE_INDEX,
NL80211_SAR_ATTR_SPECS_START_FREQ,
NL80211_SAR_ATTR_SPECS_END_FREQ,
__NL80211_SAR_ATTR_SPECS_LAST,
NL80211_SAR_ATTR_SPECS_MAX = __NL80211_SAR_ATTR_SPECS_LAST - 1,
};
#endif /* __LINUX_NL80211_H */

View File

@ -434,6 +434,7 @@ enum {
TCA_HTB_RATE64,
TCA_HTB_CEIL64,
TCA_HTB_PAD,
TCA_HTB_OFFLOAD,
__TCA_HTB_MAX,
};

View File

@ -178,6 +178,13 @@ enum {
RTM_GETVLAN,
#define RTM_GETVLAN RTM_GETVLAN
RTM_NEWNEXTHOPBUCKET = 116,
#define RTM_NEWNEXTHOPBUCKET RTM_NEWNEXTHOPBUCKET
RTM_DELNEXTHOPBUCKET,
#define RTM_DELNEXTHOPBUCKET RTM_DELNEXTHOPBUCKET
RTM_GETNEXTHOPBUCKET,
#define RTM_GETNEXTHOPBUCKET RTM_GETNEXTHOPBUCKET
__RTM_MAX,
#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
};
@ -283,6 +290,7 @@ enum {
#define RTPROT_MROUTED 17 /* Multicast daemon */
#define RTPROT_KEEPALIVED 18 /* Keepalived daemon */
#define RTPROT_BABEL 42 /* Babel daemon */
#define RTPROT_OPENR 99 /* Open Routing (Open/R) Routes */
#define RTPROT_BGP 186 /* BGP Routes */
#define RTPROT_ISIS 187 /* ISIS Routes */
#define RTPROT_OSPF 188 /* OSPF Routes */
@ -319,6 +327,11 @@ enum rt_scope_t {
#define RTM_F_FIB_MATCH 0x2000 /* return full fib lookup match */
#define RTM_F_OFFLOAD 0x4000 /* route is offloaded */
#define RTM_F_TRAP 0x8000 /* route is trapping packets */
#define RTM_F_OFFLOAD_FAILED 0x20000000 /* route offload failed, this value
* is chosen to avoid conflicts with
* other flags defined in
* include/uapi/linux/ipv6_route.h
*/
/* Reserved table identifiers */
@ -396,11 +409,13 @@ struct rtnexthop {
#define RTNH_F_DEAD 1 /* Nexthop is dead (used by multipath) */
#define RTNH_F_PERVASIVE 2 /* Do recursive gateway lookup */
#define RTNH_F_ONLINK 4 /* Gateway is forced on link */
#define RTNH_F_OFFLOAD 8 /* offloaded route */
#define RTNH_F_OFFLOAD 8 /* Nexthop is offloaded */
#define RTNH_F_LINKDOWN 16 /* carrier-down on nexthop */
#define RTNH_F_UNRESOLVED 32 /* The entry is unresolved (ipmr) */
#define RTNH_F_TRAP 64 /* Nexthop is trapping packets */
#define RTNH_COMPARE_MASK (RTNH_F_DEAD | RTNH_F_LINKDOWN | RTNH_F_OFFLOAD)
#define RTNH_COMPARE_MASK (RTNH_F_DEAD | RTNH_F_LINKDOWN | \
RTNH_F_OFFLOAD | RTNH_F_TRAP)
/* Macros to handle hexthops */
@ -766,12 +781,18 @@ enum {
#define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))
/* tcamsg flags stored in attribute TCA_ROOT_FLAGS
*
* TCA_FLAG_LARGE_DUMP_ON user->kernel to request for larger than TCA_ACT_MAX_PRIO
* actions in a dump. All dump responses will contain the number of actions
* being dumped stored in for user app's consumption in TCA_ROOT_COUNT
* TCA_ACT_FLAG_LARGE_DUMP_ON user->kernel to request for larger than
* TCA_ACT_MAX_PRIO actions in a dump. All dump responses will contain the
* number of actions being dumped stored in for user app's consumption in
* TCA_ROOT_COUNT
*
* TCA_ACT_FLAG_TERSE_DUMP user->kernel to request terse (brief) dump that only
* includes essential action info (kind, index, etc.)
*
*/
#define TCA_FLAG_LARGE_DUMP_ON (1 << 0)
#define TCA_ACT_FLAG_LARGE_DUMP_ON TCA_FLAG_LARGE_DUMP_ON
#define TCA_ACT_FLAG_TERSE_DUMP (1 << 1)
/* New extended info filters for IFLA_EXT_MASK */
#define RTEXT_FILTER_VF (1 << 0)
@ -779,6 +800,8 @@ enum {
#define RTEXT_FILTER_BRVLAN_COMPRESSED (1 << 2)
#define RTEXT_FILTER_SKIP_STATS (1 << 3)
#define RTEXT_FILTER_MRP (1 << 4)
#define RTEXT_FILTER_CFM_CONFIG (1 << 5)
#define RTEXT_FILTER_CFM_STATUS (1 << 6)
/* End of information exported to user level */

View File

@ -20,7 +20,6 @@
#define _sentinel_ __attribute__((__sentinel__))
#define _destructor_ __attribute__((__destructor__))
#define _deprecated_ __attribute__((__deprecated__))
#define _packed_ __attribute__((__packed__))
#define _malloc_ __attribute__((__malloc__))
#define _weak_ __attribute__((__weak__))
#define _public_ __attribute__((__visibility__("default")))

View File

@ -189,22 +189,6 @@ static inline void strncpy_exact(char *buf, const char *src, size_t buf_len) {
}
REENABLE_WARNING;
/* Like startswith(), but operates on arbitrary memory blocks */
static inline void *memory_startswith(const void *p, size_t sz, const char *token) {
assert(token);
size_t n = strlen(token);
if (sz < n)
return NULL;
assert(p);
if (memcmp(p, token, n) != 0)
return NULL;
return (uint8_t*) p + n;
}
/* Like startswith_no_case(), but operates on arbitrary memory blocks.
* It works only for ASCII strings.
*/

View File

@ -22,7 +22,7 @@
#endif
/* magic string to find in the binary image */
static const char __attribute__((used)) magic[] = "#### LoaderInfo: systemd-boot " GIT_VERSION " ####";
static const char _used_ _section_(".sdmagic") magic[] = "#### LoaderInfo: systemd-boot " GIT_VERSION " ####";
enum loader_type {
LOADER_UNDEFINED,
@ -1792,6 +1792,29 @@ static ConfigEntry *config_entry_add_loader(
return entry;
}
static BOOLEAN is_sd_boot(EFI_FILE *root_dir, const CHAR16 *loader_path) {
EFI_STATUS err;
const CHAR8 *sections[] = {
(CHAR8 *)".sdmagic",
NULL
};
UINTN offset = 0, size = 0, read;
_cleanup_freepool_ CHAR8 *content = NULL;
assert(root_dir);
assert(loader_path);
err = pe_file_locate_sections(root_dir, loader_path, sections, &offset, &size);
if (EFI_ERROR(err) || size != sizeof(magic))
return FALSE;
err = file_read(root_dir, loader_path, offset, size, &content, &read);
if (EFI_ERROR(err) || size != read)
return FALSE;
return CompareMem(content, magic, sizeof(magic)) == 0;
}
static BOOLEAN config_entry_add_loader_auto(
Config *config,
EFI_HANDLE *device,
@ -1811,25 +1834,23 @@ static BOOLEAN config_entry_add_loader_auto(
assert(root_dir);
assert(id);
assert(title);
assert(loader);
assert(loader || loaded_image_path);
if (!config->auto_entries)
return FALSE;
/* do not add an entry for ourselves */
if (loaded_image_path) {
UINTN len;
_cleanup_freepool_ CHAR8 *content = NULL;
loader = L"\\EFI\\BOOT\\BOOT" EFI_MACHINE_TYPE_NAME ".efi";
if (StriCmp(loader, loaded_image_path) == 0)
/* We are trying to add the default EFI loader here,
* but we do not want to do that if that would be us.
*
* If the default loader is not us, it might be shim. It would
* chainload GRUBX64.EFI in that case, which might be us.*/
if (StriCmp(loader, loaded_image_path) == 0 ||
is_sd_boot(root_dir, loader) ||
is_sd_boot(root_dir, L"\\EFI\\BOOT\\GRUB" EFI_MACHINE_TYPE_NAME L".EFI"))
return FALSE;
/* look for systemd-boot magic string */
err = file_read(root_dir, loader, 0, 100*1024, &content, &len);
if (!EFI_ERROR(err))
for (CHAR8 *start = content; start <= content + len - sizeof(magic) - 1; start++)
if (start[0] == magic[0] && CompareMem(start, magic, sizeof(magic) - 1) == 0)
return FALSE;
}
/* check existence */
@ -1876,6 +1897,55 @@ static VOID config_entry_add_osx(Config *config) {
}
}
static VOID config_entry_add_windows(Config *config, EFI_HANDLE *device, EFI_FILE *root_dir) {
_cleanup_freepool_ CHAR8 *bcd = NULL;
const CHAR16 *title = NULL;
EFI_STATUS err;
UINTN len;
assert(config);
assert(device);
assert(root_dir);
if (!config->auto_entries)
return;
/* Try to find a better title. */
err = file_read(root_dir, L"\\EFI\\Microsoft\\Boot\\BCD", 0, 100*1024, &bcd, &len);
if (!EFI_ERROR(err)) {
static const CHAR16 *versions[] = {
L"Windows 11",
L"Windows 10",
L"Windows 8.1",
L"Windows 8",
L"Windows 7",
L"Windows Vista",
};
CHAR8 *p = bcd;
while (!title) {
CHAR8 *q = mempmem_safe(p, len, versions[0], STRLEN(L"Windows "));
if (!q)
break;
len -= q - p;
p = q;
/* We found the prefix, now try all the version strings. */
for (UINTN i = 0; i < ELEMENTSOF(versions); i++) {
if (memory_startswith(p, len, versions[i] + STRLEN("Windows "))) {
title = versions[i];
break;
}
}
}
}
config_entry_add_loader_auto(config, device, root_dir, NULL,
L"auto-windows", 'w', title ?: L"Windows Boot Manager",
L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi");
}
static VOID config_entry_add_linux(
Config *config,
EFI_HANDLE *device,
@ -1897,14 +1967,13 @@ static VOID config_entry_add_linux(
CHAR16 buf[256];
UINTN bufsize = sizeof buf;
EFI_FILE_INFO *f;
CHAR8 *sections[] = {
const CHAR8 *sections[] = {
(CHAR8 *)".osrel",
(CHAR8 *)".cmdline",
NULL
};
UINTN offs[ELEMENTSOF(sections)-1] = {};
UINTN szs[ELEMENTSOF(sections)-1] = {};
UINTN addrs[ELEMENTSOF(sections)-1] = {};
CHAR8 *content = NULL;
CHAR8 *line;
UINTN pos = 0;
@ -1931,7 +2000,7 @@ static VOID config_entry_add_linux(
continue;
/* look for .osrel and .cmdline sections in the .efi binary */
err = pe_file_locate_sections(linux_dir, f->FileName, sections, addrs, offs, szs);
err = pe_file_locate_sections(linux_dir, f->FileName, sections, offs, szs);
if (EFI_ERROR(err))
continue;
@ -2410,13 +2479,12 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
config_sort_entries(&config);
/* if we find some well-known loaders, add them to the end of the list */
config_entry_add_loader_auto(&config, loaded_image->DeviceHandle, root_dir, NULL,
L"auto-windows", 'w', L"Windows Boot Manager", L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi");
config_entry_add_osx(&config);
config_entry_add_windows(&config, loaded_image->DeviceHandle, root_dir);
config_entry_add_loader_auto(&config, loaded_image->DeviceHandle, root_dir, NULL,
L"auto-efi-shell", 's', L"EFI Shell", L"\\shell" EFI_MACHINE_TYPE_NAME ".efi");
config_entry_add_loader_auto(&config, loaded_image->DeviceHandle, root_dir, loaded_image_path,
L"auto-efi-default", '\0', L"EFI Default Loader", L"\\EFI\\Boot\\boot" EFI_MACHINE_TYPE_NAME ".efi");
config_entry_add_osx(&config);
L"auto-efi-default", '\0', L"EFI Default Loader", NULL);
if (config.auto_firmware && efivar_get_uint64_le(EFI_GLOBAL_GUID, L"OsIndicationsSupported", &osind) == EFI_SUCCESS) {
if (osind & EFI_OS_INDICATIONS_BOOT_TO_FW_UI)

View File

@ -2,6 +2,7 @@
#pragma once
#include <efi.h>
#include "macro-fundamental.h"
#define SETUP_MAGIC 0x53726448 /* "HdrS" */
@ -44,7 +45,7 @@ struct setup_header {
UINT64 pref_address;
UINT32 init_size;
UINT32 handover_offset;
} __attribute__((packed));
} _packed_;
/* adapted from linux' bootparam.h */
struct boot_params {
@ -81,7 +82,7 @@ struct boot_params {
UINT8 _pad8[48];
UINT8 eddbuf[6*82]; // was: struct edd_info eddbuf[EDDMAXNR]
UINT8 _pad9[276];
} __attribute__((packed));
} _packed_;
EFI_STATUS linux_exec(EFI_HANDLE *image,
CHAR8 *cmdline, UINTN cmdline_size,

View File

@ -133,13 +133,13 @@ typedef struct {
UINT16 HeaderVersion;
UINT32 PCRIndex;
UINT32 EventType;
} __attribute__((packed)) EFI_TCG2_EVENT_HEADER;
} _packed_ EFI_TCG2_EVENT_HEADER;
typedef struct tdEFI_TCG2_EVENT {
UINT32 Size;
EFI_TCG2_EVENT_HEADER Header;
UINT8 Event[1];
} __attribute__((packed)) EFI_TCG2_EVENT;
} _packed_ EFI_TCG2_EVENT;
typedef EFI_STATUS(EFIAPI * EFI_TCG2_GET_CAPABILITY) (IN EFI_TCG2_PROTOCOL * This,
IN OUT EFI_TCG2_BOOT_SERVICE_CAPABILITY * ProtocolCapability);

View File

@ -292,6 +292,7 @@ if have_gnu_efi
'-j', '.text',
'-j', '.sdata',
'-j', '.sbat',
'-j', '.sdmagic',
'-j', '.data',
'-j', '.dynamic',
'-j', '.dynsym',

View File

@ -120,3 +120,7 @@ typedef struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL {
} EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL;
#endif
#ifndef EFI_IMAGE_MACHINE_RISCV64
#define EFI_IMAGE_MACHINE_RISCV64 0x5064
#endif

View File

@ -6,6 +6,24 @@
#include "pe.h"
#include "util.h"
#define DOS_FILE_MAGIC "MZ"
#define PE_FILE_MAGIC "PE\0\0"
#define MAX_SECTIONS 96
#if defined(__i386__)
#define TARGET_MACHINE_TYPE EFI_IMAGE_MACHINE_IA32
#elif defined(__x86_64__)
#define TARGET_MACHINE_TYPE EFI_IMAGE_MACHINE_X64
#elif defined(__aarch64__)
#define TARGET_MACHINE_TYPE EFI_IMAGE_MACHINE_AARCH64
#elif defined(__arm__)
#define TARGET_MACHINE_TYPE EFI_IMAGE_MACHINE_ARMTHUMB_MIXED
#elif defined(__riscv) && __riscv_xlen == 64
#define TARGET_MACHINE_TYPE EFI_IMAGE_MACHINE_RISCV64
#else
#error Unknown EFI arch
#endif
struct DosFileHeader {
UINT8 Magic[2];
UINT16 LastSize;
@ -26,14 +44,9 @@ struct DosFileHeader {
UINT16 OEMInfo;
UINT16 reserved2[10];
UINT32 ExeHeader;
} __attribute__((packed));
} _packed_;
#define PE_HEADER_MACHINE_I386 0x014c
#define PE_HEADER_MACHINE_X64 0x8664
#define PE_HEADER_MACHINE_ARM64 0xaa64
#define PE_HEADER_MACHINE_ARM 0x01c2
#define PE_HEADER_MACHINE_RISCV64 0x5064
struct PeFileHeader {
struct CoffFileHeader {
UINT16 Machine;
UINT16 NumberOfSections;
UINT32 TimeDateStamp;
@ -41,12 +54,13 @@ struct PeFileHeader {
UINT32 NumberOfSymbols;
UINT16 SizeOfOptionalHeader;
UINT16 Characteristics;
} __attribute__((packed));
} _packed_;
struct PeHeader {
struct PeFileHeader {
UINT8 Magic[4];
struct PeFileHeader FileHeader;
} __attribute__((packed));
struct CoffFileHeader FileHeader;
/* OptionalHeader omitted */
} _packed_;
struct PeSectionHeader {
UINT8 Name[8];
@ -59,120 +73,143 @@ struct PeSectionHeader {
UINT16 NumberOfRelocations;
UINT16 NumberOfLinenumbers;
UINT32 Characteristics;
} __attribute__((packed));
} _packed_;
EFI_STATUS pe_memory_locate_sections(CHAR8 *base, CHAR8 **sections, UINTN *addrs, UINTN *offsets, UINTN *sizes) {
struct DosFileHeader *dos;
struct PeHeader *pe;
UINTN offset;
static inline BOOLEAN verify_dos(const struct DosFileHeader *dos) {
assert(dos);
return CompareMem(dos->Magic, DOS_FILE_MAGIC, STRLEN(DOS_FILE_MAGIC)) == 0;
}
assert(base);
static inline BOOLEAN verify_pe(const struct PeFileHeader *pe) {
assert(pe);
return CompareMem(pe->Magic, PE_FILE_MAGIC, STRLEN(PE_FILE_MAGIC)) == 0 &&
pe->FileHeader.Machine == TARGET_MACHINE_TYPE &&
pe->FileHeader.NumberOfSections > 0 &&
pe->FileHeader.NumberOfSections <= MAX_SECTIONS;
}
static inline UINTN section_table_offset(const struct DosFileHeader *dos, const struct PeFileHeader *pe) {
assert(dos);
assert(pe);
return dos->ExeHeader + sizeof(struct PeFileHeader) + pe->FileHeader.SizeOfOptionalHeader;
}
static VOID locate_sections(
const struct PeSectionHeader section_table[],
UINTN n_table,
const CHAR8 **sections,
UINTN *addrs,
UINTN *offsets,
UINTN *sizes) {
assert(section_table);
assert(sections);
assert(sizes);
dos = (struct DosFileHeader *)base;
for (UINTN i = 0; i < n_table; i++) {
const struct PeSectionHeader *sect = section_table + i;
if (CompareMem(dos->Magic, "MZ", 2) != 0)
return EFI_LOAD_ERROR;
pe = (struct PeHeader *)&base[dos->ExeHeader];
if (CompareMem(pe->Magic, "PE\0\0", 4) != 0)
return EFI_LOAD_ERROR;
/* PE32+ Subsystem type */
if (pe->FileHeader.Machine != PE_HEADER_MACHINE_X64 &&
pe->FileHeader.Machine != PE_HEADER_MACHINE_ARM64 &&
pe->FileHeader.Machine != PE_HEADER_MACHINE_I386 &&
pe->FileHeader.Machine != PE_HEADER_MACHINE_ARM &&
pe->FileHeader.Machine != PE_HEADER_MACHINE_RISCV64)
return EFI_LOAD_ERROR;
if (pe->FileHeader.NumberOfSections > 96)
return EFI_LOAD_ERROR;
offset = dos->ExeHeader + sizeof(*pe) + pe->FileHeader.SizeOfOptionalHeader;
for (UINTN i = 0; i < pe->FileHeader.NumberOfSections; i++) {
struct PeSectionHeader *sect;
sect = (struct PeSectionHeader *)&base[offset];
for (UINTN j = 0; sections[j]; j++) {
if (CompareMem(sect->Name, sections[j], strlena(sections[j])) != 0)
continue;
if (addrs)
addrs[j] = (UINTN)sect->VirtualAddress;
addrs[j] = sect->VirtualAddress;
if (offsets)
offsets[j] = (UINTN)sect->PointerToRawData;
if (sizes)
sizes[j] = (UINTN)sect->VirtualSize;
offsets[j] = sect->PointerToRawData;
sizes[j] = sect->VirtualSize;
}
offset += sizeof(*sect);
}
}
EFI_STATUS pe_memory_locate_sections(
const CHAR8 *base,
const CHAR8 **sections,
UINTN *addrs,
UINTN *sizes) {
const struct DosFileHeader *dos;
const struct PeFileHeader *pe;
UINTN offset;
assert(base);
assert(sections);
assert(addrs);
assert(sizes);
dos = (const struct DosFileHeader*)base;
if (!verify_dos(dos))
return EFI_LOAD_ERROR;
pe = (const struct PeFileHeader*)&base[dos->ExeHeader];
if (!verify_pe(pe))
return EFI_LOAD_ERROR;
offset = section_table_offset(dos, pe);
locate_sections((struct PeSectionHeader*)&base[offset], pe->FileHeader.NumberOfSections,
sections, addrs, NULL, sizes);
return EFI_SUCCESS;
}
EFI_STATUS pe_file_locate_sections(EFI_FILE *dir, CHAR16 *path, CHAR8 **sections, UINTN *addrs, UINTN *offsets, UINTN *sizes) {
EFI_FILE_HANDLE handle;
EFI_STATUS pe_file_locate_sections(
EFI_FILE *dir,
const CHAR16 *path,
const CHAR8 **sections,
UINTN *offsets,
UINTN *sizes) {
_cleanup_freepool_ struct PeSectionHeader *section_table = NULL;
_cleanup_(FileHandleClosep) EFI_FILE_HANDLE handle = NULL;
struct DosFileHeader dos;
struct PeHeader pe;
UINTN len;
UINTN headerlen;
struct PeFileHeader pe;
UINTN len, section_table_len;
EFI_STATUS err;
_cleanup_freepool_ CHAR8 *header = NULL;
assert(dir);
assert(path);
assert(sections);
assert(offsets);
assert(sizes);
err = uefi_call_wrapper(dir->Open, 5, dir, &handle, path, EFI_FILE_MODE_READ, 0ULL);
err = uefi_call_wrapper(dir->Open, 5, dir, &handle, (CHAR16*)path, EFI_FILE_MODE_READ, 0ULL);
if (EFI_ERROR(err))
return err;
/* MS-DOS stub */
len = sizeof(dos);
err = uefi_call_wrapper(handle->Read, 3, handle, &len, &dos);
if (EFI_ERROR(err))
goto out;
if (len != sizeof(dos)) {
err = EFI_LOAD_ERROR;
goto out;
}
return err;
if (len != sizeof(dos) || !verify_dos(&dos))
return EFI_LOAD_ERROR;
err = uefi_call_wrapper(handle->SetPosition, 2, handle, dos.ExeHeader);
if (EFI_ERROR(err))
goto out;
return err;
len = sizeof(pe);
err = uefi_call_wrapper(handle->Read, 3, handle, &len, &pe);
if (EFI_ERROR(err))
goto out;
if (len != sizeof(pe)) {
err = EFI_LOAD_ERROR;
goto out;
}
return err;
if (len != sizeof(pe) || !verify_pe(&pe))
return EFI_LOAD_ERROR;
headerlen = sizeof(dos) + sizeof(pe) + pe.FileHeader.SizeOfOptionalHeader + pe.FileHeader.NumberOfSections * sizeof(struct PeSectionHeader);
header = AllocatePool(headerlen);
if (!header) {
err = EFI_OUT_OF_RESOURCES;
goto out;
}
len = headerlen;
err = uefi_call_wrapper(handle->SetPosition, 2, handle, 0);
section_table_len = pe.FileHeader.NumberOfSections * sizeof(struct PeSectionHeader);
section_table = AllocatePool(section_table_len);
if (!section_table)
return EFI_OUT_OF_RESOURCES;
err = uefi_call_wrapper(handle->SetPosition, 2, handle, section_table_offset(&dos, &pe));
if (EFI_ERROR(err))
goto out;
return err;
err = uefi_call_wrapper(handle->Read, 3, handle, &len, header);
len = section_table_len;
err = uefi_call_wrapper(handle->Read, 3, handle, &len, section_table);
if (EFI_ERROR(err))
goto out;
return err;
if (len != section_table_len)
return EFI_LOAD_ERROR;
if (len != headerlen) {
err = EFI_LOAD_ERROR;
goto out;
}
locate_sections(section_table, pe.FileHeader.NumberOfSections,
sections, NULL, offsets, sizes);
err = pe_memory_locate_sections(header, sections, addrs, offsets, sizes);
out:
uefi_call_wrapper(handle->Close, 1, handle);
return err;
return EFI_SUCCESS;
}

View File

@ -1,9 +1,17 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <efi.h>
#include <efidef.h>
EFI_STATUS pe_memory_locate_sections(CHAR8 *base,
CHAR8 **sections, UINTN *addrs, UINTN *offsets, UINTN *sizes);
EFI_STATUS pe_file_locate_sections(EFI_FILE *dir, CHAR16 *path,
CHAR8 **sections, UINTN *addrs, UINTN *offsets, UINTN *sizes);
EFI_STATUS pe_memory_locate_sections(
const CHAR8 *base,
const CHAR8 **sections,
UINTN *addrs,
UINTN *sizes);
EFI_STATUS pe_file_locate_sections(
EFI_FILE *dir,
const CHAR16 *path,
const CHAR8 **sections,
UINTN *offsets,
UINTN *sizes);

View File

@ -12,7 +12,7 @@ struct bmp_file {
UINT32 size;
UINT16 reserved[2];
UINT32 offset;
} __attribute__((packed));
} _packed_;
/* we require at least BITMAPINFOHEADER, later versions are
accepted, but their features ignored */
@ -28,14 +28,14 @@ struct bmp_dib {
INT32 y_pixel_meter;
UINT32 colors_used;
UINT32 colors_important;
} __attribute__((packed));
} _packed_;
struct bmp_map {
UINT8 blue;
UINT8 green;
UINT8 red;
UINT8 reserved;
} __attribute__((packed));
} _packed_;
static EFI_STATUS bmp_parse_header(UINT8 *bmp, UINTN size, struct bmp_dib **ret_dib,
struct bmp_map **ret_map, UINT8 **pixmap) {

View File

@ -17,7 +17,7 @@ static const char __attribute__((used)) magic[] = "#### LoaderInfo: systemd-stub
EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
EFI_LOADED_IMAGE *loaded_image;
CHAR8 *sections[] = {
const CHAR8 *sections[] = {
(CHAR8 *)".cmdline",
(CHAR8 *)".linux",
(CHAR8 *)".initrd",
@ -25,7 +25,6 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
NULL
};
UINTN addrs[ELEMENTSOF(sections)-1] = {};
UINTN offs[ELEMENTSOF(sections)-1] = {};
UINTN szs[ELEMENTSOF(sections)-1] = {};
CHAR8 *cmdline = NULL;
UINTN cmdline_len;
@ -39,7 +38,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
if (EFI_ERROR(err))
return log_error_status_stall(err, L"Error getting a LoadedImageProtocol handle: %r", err);
err = pe_memory_locate_sections(loaded_image->ImageBase, sections, addrs, offs, szs);
err = pe_memory_locate_sections(loaded_image->ImageBase, sections, addrs, szs);
if (EFI_ERROR(err))
return log_error_status_stall(err, L"Unable to locate embedded .linux section: %r", err);

View File

@ -501,3 +501,17 @@ EFI_STATUS log_oom(void) {
log_error_stall(L"Out of memory.");
return EFI_OUT_OF_RESOURCES;
}
VOID *memmem_safe(const VOID *haystack, UINTN haystack_len, const VOID *needle, UINTN needle_len) {
assert(haystack || haystack_len == 0);
assert(needle || needle_len == 0);
if (needle_len == 0)
return (VOID*)haystack;
for (const CHAR8 *h = haystack, *n = needle; haystack_len >= needle_len; h++, haystack_len--)
if (*h == *n && CompareMem(h + 1, n + 1, needle_len - 1) == 0)
return (VOID*)h;
return NULL;
}

View File

@ -84,3 +84,10 @@ EFI_STATUS log_oom(void);
log_error_stall(fmt, ##__VA_ARGS__); \
err; \
})
VOID *memmem_safe(const VOID *haystack, UINTN haystack_len, const VOID *needle, UINTN needle_len);
static inline VOID *mempmem_safe(const VOID *haystack, UINTN haystack_len, const VOID *needle, UINTN needle_len) {
CHAR8 *p = memmem_safe(haystack, haystack_len, needle, needle_len);
return p ? p + needle_len : NULL;
}

View File

@ -3588,7 +3588,6 @@ int unit_add_blockdev_dependency(Unit *u, const char *what, UnitDependencyMask m
int unit_coldplug(Unit *u) {
int r = 0, q;
char **i;
Job *uj;
assert(u);
@ -3611,9 +3610,13 @@ int unit_coldplug(Unit *u) {
r = q;
}
uj = u->job ?: u->nop_job;
if (uj) {
q = job_coldplug(uj);
if (u->job) {
q = job_coldplug(u->job);
if (q < 0 && r >= 0)
r = q;
}
if (u->nop_job) {
q = job_coldplug(u->nop_job);
if (q < 0 && r >= 0)
r = q;
}

View File

@ -11,6 +11,7 @@
#define _const_ __attribute__((__const__))
#define _pure_ __attribute__((__pure__))
#define _section_(x) __attribute__((__section__(x)))
#define _packed_ __attribute__((__packed__))
#define _used_ __attribute__((__used__))
#define _unused_ __attribute__((__unused__))
#define _cleanup_(x) __attribute__((__cleanup__(x)))

View File

@ -16,6 +16,7 @@
#define strncmp(a, b, n) StrnCmp((a), (b), (n))
#define strcasecmp(a, b) StriCmp((a), (b))
#define STR_C(str) (L ## str)
#define memcmp(a, b, n) CompareMem(a, b, n)
#else
#define STR_C(str) (str)
#endif
@ -65,3 +66,19 @@ static inline const sd_char *yes_no(sd_bool b) {
}
sd_int strverscmp_improved(const sd_char *a, const sd_char *b);
/* Like startswith(), but operates on arbitrary memory blocks */
static inline void *memory_startswith(const void *p, sd_size_t sz, const sd_char *token) {
assert(token);
sd_size_t n = strlen(token) * sizeof(sd_char);
if (sz < n)
return NULL;
assert(p);
if (memcmp(p, token, n) != 0)
return NULL;
return (uint8_t*) p + n;
}

View File

@ -164,16 +164,18 @@ static int netdev_geneve_create(NetDev *netdev) {
return r;
}
int config_parse_geneve_vni(const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int config_parse_geneve_vni(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
Geneve *v = userdata;
uint32_t f;
int r;
@ -199,16 +201,18 @@ int config_parse_geneve_vni(const char *unit,
return 0;
}
int config_parse_geneve_address(const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int config_parse_geneve_address(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
Geneve *v = userdata;
union in_addr_union *addr = data, buffer;
int r, f;
@ -236,16 +240,18 @@ int config_parse_geneve_address(const char *unit,
return 0;
}
int config_parse_geneve_flow_label(const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int config_parse_geneve_flow_label(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
Geneve *v = userdata;
uint32_t f;
int r;
@ -272,16 +278,18 @@ int config_parse_geneve_flow_label(const char *unit,
return 0;
}
int config_parse_geneve_ttl(const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int config_parse_geneve_ttl(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
Geneve *v = userdata;
unsigned f;
int r;

View File

@ -5,6 +5,7 @@
#include "conf-parser.h"
#include "macvlan.h"
#include "macvlan-util.h"
#include "networkd-network.h"
#include "parse-util.h"
DEFINE_CONFIG_PARSE_ENUM(config_parse_macvlan_mode, macvlan_mode, MacVlanMode, "Failed to parse macvlan mode");
@ -16,6 +17,7 @@ static int netdev_macvlan_fill_message_create(NetDev *netdev, Link *link, sd_net
assert(netdev);
assert(link);
assert(netdev->ifname);
assert(link->network);
if (netdev->kind == NETDEV_KIND_MACVLAN)
m = MACVLAN(netdev);
@ -52,6 +54,13 @@ static int netdev_macvlan_fill_message_create(NetDev *netdev, Link *link, sd_net
return log_netdev_error_errno(netdev, r, "Could not append IFLA_MACVLAN_MODE attribute: %m");
}
/* set the nopromisc flag if Promiscuous= of the link is explicitly set to false */
if (m->mode == NETDEV_MACVLAN_MODE_PASSTHRU && link->network->promiscuous == 0) {
r = sd_netlink_message_append_u16(req, IFLA_MACVLAN_FLAGS, MACVLAN_FLAG_NOPROMISC);
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_MACVLAN_FLAGS attribute: %m");
}
if (m->bc_queue_length != UINT32_MAX) {
r = sd_netlink_message_append_u32(req, IFLA_MACVLAN_BC_QUEUE_LEN, m->bc_queue_length);
if (r < 0)

View File

@ -501,16 +501,18 @@ static int netdev_tunnel_verify(NetDev *netdev, const char *filename) {
return 0;
}
int config_parse_tunnel_address(const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int config_parse_tunnel_address(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
Tunnel *t = userdata;
union in_addr_union *addr = data, buffer;
int r, f;
@ -555,16 +557,18 @@ int config_parse_tunnel_address(const char *unit,
return 0;
}
int config_parse_tunnel_key(const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int config_parse_tunnel_key(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
union in_addr_union buffer;
Tunnel *t = userdata;
uint32_t k;
@ -596,16 +600,18 @@ int config_parse_tunnel_key(const char *unit,
return 0;
}
int config_parse_ipv6_flowlabel(const char* unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int config_parse_ipv6_flowlabel(
const char* unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
IPv6FlowLabel *ipv6_flowlabel = data;
Tunnel *t = userdata;
int k = 0;
@ -635,16 +641,18 @@ int config_parse_ipv6_flowlabel(const char* unit,
return 0;
}
int config_parse_encap_limit(const char* unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int config_parse_encap_limit(
const char* unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
Tunnel *t = userdata;
int k = 0;
int r;
@ -673,26 +681,27 @@ int config_parse_encap_limit(const char* unit,
return 0;
}
int config_parse_6rd_prefix(const char* unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int config_parse_6rd_prefix(
const char* unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
Tunnel *t = userdata;
union in_addr_union p;
uint8_t l;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
union in_addr_union p;
uint8_t l;
int r;
r = in_addr_prefix_from_string(rvalue, AF_INET6, &p, &l);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse 6rd prefix \"%s\", ignoring: %m", rvalue);

View File

@ -174,16 +174,18 @@ static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_netli
return r;
}
int config_parse_vxlan_address(const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int config_parse_vxlan_address(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
VxLan *v = userdata;
union in_addr_union *addr = data, buffer;
int r, f;
@ -225,16 +227,18 @@ int config_parse_vxlan_address(const char *unit,
return 0;
}
int config_parse_port_range(const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int config_parse_port_range(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
VxLan *v = userdata;
uint16_t low, high;
int r;
@ -257,16 +261,18 @@ int config_parse_port_range(const char *unit,
return 0;
}
int config_parse_flow_label(const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int config_parse_flow_label(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
VxLan *v = userdata;
unsigned f;
int r;
@ -293,16 +299,18 @@ int config_parse_flow_label(const char *unit,
return 0;
}
int config_parse_vxlan_ttl(const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int config_parse_vxlan_ttl(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
VxLan *v = userdata;
unsigned f;
int r;

View File

@ -10,7 +10,132 @@
#include "parse-util.h"
#include "string-util.h"
#define CAN_TERMINATION_OHM_VALUE 120
#define CAN_TERMINATION_DEFAULT_OHM_VALUE 120
int can_set_netlink_message(Link *link, sd_netlink_message *m) {
int r;
assert(link);
assert(link->network);
assert(m);
r = sd_netlink_message_set_flags(m, NLM_F_REQUEST | NLM_F_ACK);
if (r < 0)
return log_link_debug_errno(link, r, "Could not set netlink flags: %m");
r = sd_netlink_message_open_container(m, IFLA_LINKINFO);
if (r < 0)
return log_link_debug_errno(link, r, "Failed to open IFLA_LINKINFO container: %m");
r = sd_netlink_message_open_container_union(m, IFLA_INFO_DATA, link->kind);
if (r < 0)
return log_link_debug_errno(link, r, "Could not open IFLA_INFO_DATA container: %m");
if (link->network->can_bitrate > 0) {
struct can_bittiming bt = {
.bitrate = link->network->can_bitrate,
.sample_point = link->network->can_sample_point,
.sjw = link->network->can_sync_jump_width,
};
log_link_debug(link, "Setting bitrate = %d bit/s", bt.bitrate);
if (link->network->can_sample_point > 0)
log_link_debug(link, "Setting sample point = %d.%d%%", bt.sample_point / 10, bt.sample_point % 10);
else
log_link_debug(link, "Using default sample point");
r = sd_netlink_message_append_data(m, IFLA_CAN_BITTIMING, &bt, sizeof(bt));
if (r < 0)
return log_link_debug_errno(link, r, "Could not append IFLA_CAN_BITTIMING attribute: %m");
} else if (link->network->can_time_quanta_ns > 0) {
struct can_bittiming bt = {
.tq = link->network->can_time_quanta_ns,
.prop_seg = link->network->can_propagation_segment,
.phase_seg1 = link->network->can_phase_buffer_segment_1,
.phase_seg2 = link->network->can_phase_buffer_segment_2,
.sjw = link->network->can_sync_jump_width,
};
log_link_debug(link, "Setting time quanta = %"PRIu32" nsec", bt.tq);
r = sd_netlink_message_append_data(m, IFLA_CAN_BITTIMING, &bt, sizeof(bt));
if (r < 0)
return log_link_debug_errno(link, r, "Could not append IFLA_CAN_BITTIMING attribute: %m");
}
if (link->network->can_data_bitrate > 0) {
struct can_bittiming bt = {
.bitrate = link->network->can_data_bitrate,
.sample_point = link->network->can_data_sample_point,
.sjw = link->network->can_data_sync_jump_width,
};
log_link_debug(link, "Setting data bitrate = %d bit/s", bt.bitrate);
if (link->network->can_data_sample_point > 0)
log_link_debug(link, "Setting data sample point = %d.%d%%", bt.sample_point / 10, bt.sample_point % 10);
else
log_link_debug(link, "Using default data sample point");
r = sd_netlink_message_append_data(m, IFLA_CAN_DATA_BITTIMING, &bt, sizeof(bt));
if (r < 0)
return log_link_debug_errno(link, r, "Could not append IFLA_CAN_DATA_BITTIMING attribute: %m");
} else if (link->network->can_data_time_quanta_ns > 0) {
struct can_bittiming bt = {
.tq = link->network->can_data_time_quanta_ns,
.prop_seg = link->network->can_data_propagation_segment,
.phase_seg1 = link->network->can_data_phase_buffer_segment_1,
.phase_seg2 = link->network->can_data_phase_buffer_segment_2,
.sjw = link->network->can_data_sync_jump_width,
};
log_link_debug(link, "Setting data time quanta = %"PRIu32" nsec", bt.tq);
r = sd_netlink_message_append_data(m, IFLA_CAN_DATA_BITTIMING, &bt, sizeof(bt));
if (r < 0)
return log_link_debug_errno(link, r, "Could not append IFLA_CAN_DATA_BITTIMING attribute: %m");
}
if (link->network->can_restart_us > 0) {
uint64_t restart_ms;
if (link->network->can_restart_us == USEC_INFINITY)
restart_ms = 0;
else
restart_ms = DIV_ROUND_UP(link->network->can_restart_us, USEC_PER_MSEC);
log_link_debug(link, "Setting restart = %s", FORMAT_TIMESPAN(restart_ms * 1000, MSEC_PER_SEC));
r = sd_netlink_message_append_u32(m, IFLA_CAN_RESTART_MS, restart_ms);
if (r < 0)
return log_link_debug_errno(link, r, "Could not append IFLA_CAN_RESTART_MS attribute: %m");
}
if (link->network->can_control_mode_mask != 0) {
struct can_ctrlmode cm = {
.mask = link->network->can_control_mode_mask,
.flags = link->network->can_control_mode_flags,
};
r = sd_netlink_message_append_data(m, IFLA_CAN_CTRLMODE, &cm, sizeof(cm));
if (r < 0)
return log_link_debug_errno(link, r, "Could not append IFLA_CAN_CTRLMODE attribute: %m");
}
if (link->network->can_termination_set) {
log_link_debug(link, "Setting can-termination to '%u'.", link->network->can_termination);
r = sd_netlink_message_append_u16(m, IFLA_CAN_TERMINATION, link->network->can_termination);
if (r < 0)
return log_link_debug_errno(link, r, "Could not append IFLA_CAN_TERMINATION attribute: %m");
}
r = sd_netlink_message_close_container(m);
if (r < 0)
return log_link_debug_errno(link, r, "Failed to close IFLA_INFO_DATA container: %m");
r = sd_netlink_message_close_container(m);
if (r < 0)
return log_link_debug_errno(link, r, "Failed to close IFLA_LINKINFO container: %m");
return 0;
}
int config_parse_can_bitrate(
const char* unit,
@ -52,131 +177,164 @@ int config_parse_can_bitrate(
return 0;
}
int can_set_netlink_message(Link *link, sd_netlink_message *m) {
struct can_ctrlmode cm = {};
int config_parse_can_time_quanta(
const char* unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
nsec_t val, *tq = data;
int r;
assert(link);
assert(link->network);
assert(m);
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
r = sd_netlink_message_set_flags(m, NLM_F_REQUEST | NLM_F_ACK);
if (r < 0)
return log_link_debug_errno(link, r, "Could not set netlink flags: %m");
r = sd_netlink_message_open_container(m, IFLA_LINKINFO);
if (r < 0)
return log_link_debug_errno(link, r, "Failed to open IFLA_LINKINFO container: %m");
r = sd_netlink_message_open_container_union(m, IFLA_INFO_DATA, link->kind);
if (r < 0)
return log_link_debug_errno(link, r, "Could not open IFLA_INFO_DATA container: %m");
if (link->network->can_bitrate > 0 || link->network->can_sample_point > 0) {
struct can_bittiming bt = {
.bitrate = link->network->can_bitrate,
.sample_point = link->network->can_sample_point,
};
log_link_debug(link, "Setting bitrate = %d bit/s", bt.bitrate);
if (link->network->can_sample_point > 0)
log_link_debug(link, "Setting sample point = %d.%d%%", bt.sample_point / 10, bt.sample_point % 10);
else
log_link_debug(link, "Using default sample point");
r = sd_netlink_message_append_data(m, IFLA_CAN_BITTIMING, &bt, sizeof(bt));
if (r < 0)
return log_link_debug_errno(link, r, "Could not append IFLA_CAN_BITTIMING attribute: %m");
r = parse_nsec(rvalue, &val);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse can time quanta '%s', ignoring: %m", rvalue);
return 0;
}
if (link->network->can_data_bitrate > 0 || link->network->can_data_sample_point > 0) {
struct can_bittiming bt = {
.bitrate = link->network->can_data_bitrate,
.sample_point = link->network->can_data_sample_point,
};
log_link_debug(link, "Setting data bitrate = %d bit/s", bt.bitrate);
if (link->network->can_data_sample_point > 0)
log_link_debug(link, "Setting data sample point = %d.%d%%", bt.sample_point / 10, bt.sample_point % 10);
else
log_link_debug(link, "Using default data sample point");
r = sd_netlink_message_append_data(m, IFLA_CAN_DATA_BITTIMING, &bt, sizeof(bt));
if (r < 0)
return log_link_debug_errno(link, r, "Could not append IFLA_CAN_DATA_BITTIMING attribute: %m");
/* Linux uses __u32 for bitrates, so the value should not exceed that. */
if (val <= 0 || val > UINT32_MAX) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Time quanta out of permitted range 1...4294967295");
return 0;
}
if (link->network->can_restart_us > 0) {
uint64_t restart_ms;
if (link->network->can_restart_us == USEC_INFINITY)
restart_ms = 0;
else
restart_ms = DIV_ROUND_UP(link->network->can_restart_us, USEC_PER_MSEC);
if (restart_ms > UINT32_MAX)
return log_link_debug_errno(link, SYNTHETIC_ERRNO(ERANGE), "restart timeout (%s) too big.",
FORMAT_TIMESPAN(restart_ms * 1000, MSEC_PER_SEC));
log_link_debug(link, "Setting restart = %s", FORMAT_TIMESPAN(restart_ms * 1000, MSEC_PER_SEC));
r = sd_netlink_message_append_u32(m, IFLA_CAN_RESTART_MS, restart_ms);
if (r < 0)
return log_link_debug_errno(link, r, "Could not append IFLA_CAN_RESTART_MS attribute: %m");
}
if (link->network->can_fd_mode >= 0) {
cm.mask |= CAN_CTRLMODE_FD;
SET_FLAG(cm.flags, CAN_CTRLMODE_FD, link->network->can_fd_mode);
log_link_debug(link, "Setting FD mode to '%s'.", yes_no(link->network->can_fd_mode));
}
if (link->network->can_non_iso >= 0) {
cm.mask |= CAN_CTRLMODE_FD_NON_ISO;
SET_FLAG(cm.flags, CAN_CTRLMODE_FD_NON_ISO, link->network->can_non_iso);
log_link_debug(link, "Setting FD non-ISO mode to '%s'.", yes_no(link->network->can_non_iso));
}
if (link->network->can_triple_sampling >= 0) {
cm.mask |= CAN_CTRLMODE_3_SAMPLES;
SET_FLAG(cm.flags, CAN_CTRLMODE_3_SAMPLES, link->network->can_triple_sampling);
log_link_debug(link, "Setting triple-sampling to '%s'.", yes_no(link->network->can_triple_sampling));
}
if (link->network->can_berr_reporting >= 0) {
cm.mask |= CAN_CTRLMODE_BERR_REPORTING;
SET_FLAG(cm.flags, CAN_CTRLMODE_BERR_REPORTING, link->network->can_berr_reporting);
log_link_debug(link, "Setting bus error reporting to '%s'.", yes_no(link->network->can_berr_reporting));
}
if (link->network->can_listen_only >= 0) {
cm.mask |= CAN_CTRLMODE_LISTENONLY;
SET_FLAG(cm.flags, CAN_CTRLMODE_LISTENONLY, link->network->can_listen_only);
log_link_debug(link, "Setting listen-only mode to '%s'.", yes_no(link->network->can_listen_only));
}
if (cm.mask != 0) {
r = sd_netlink_message_append_data(m, IFLA_CAN_CTRLMODE, &cm, sizeof(cm));
if (r < 0)
return log_link_debug_errno(link, r, "Could not append IFLA_CAN_CTRLMODE attribute: %m");
}
if (link->network->can_termination >= 0) {
log_link_debug(link, "Setting can-termination to '%s'.", yes_no(link->network->can_termination));
r = sd_netlink_message_append_u16(m, IFLA_CAN_TERMINATION,
link->network->can_termination ? CAN_TERMINATION_OHM_VALUE : 0);
if (r < 0)
return log_link_debug_errno(link, r, "Could not append IFLA_CAN_TERMINATION attribute: %m");
}
r = sd_netlink_message_close_container(m);
if (r < 0)
return log_link_debug_errno(link, r, "Failed to close IFLA_INFO_DATA container: %m");
r = sd_netlink_message_close_container(m);
if (r < 0)
return log_link_debug_errno(link, r, "Failed to close IFLA_LINKINFO container: %m");
*tq = val;
return 0;
}
int config_parse_can_restart_usec(
const char* unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
usec_t usec, *restart_usec = data;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
r = parse_sec(rvalue, &usec);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse CAN restart sec '%s', ignoring: %m", rvalue);
return 0;
}
if (usec != USEC_INFINITY &&
DIV_ROUND_UP(usec, USEC_PER_MSEC) > UINT32_MAX) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"CAN RestartSec= must be in the range 0...%"PRIu32"ms, ignoring: %s", UINT32_MAX, rvalue);
return 0;
}
*restart_usec = usec;
return 0;
}
int config_parse_can_control_mode(
const char* unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
Network *network = userdata;
uint32_t mask = ltype;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(userdata);
assert(mask != 0);
if (isempty(rvalue)) {
network->can_control_mode_mask &= ~mask;
network->can_control_mode_flags &= ~mask;
return 0;
}
r = parse_boolean(rvalue);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse CAN control mode '%s', ignoring: %s", lvalue, rvalue);
return 0;
}
network->can_control_mode_mask |= mask;
SET_FLAG(network->can_control_mode_flags, mask, r);
return 0;
}
int config_parse_can_termination(
const char* unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
Network *network = userdata;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
if (isempty(rvalue)) {
network->can_termination_set = false;
return 0;
}
/* Note that 0 termination ohm value means no termination resistor, and there is no conflict
* between parse_boolean() and safe_atou16() when Termination=0. However, Termination=1 must be
* treated as 1 ohm, instead of true (and then the default ohm value). So, we need to parse the
* string with safe_atou16() at first. */
r = safe_atou16(rvalue, &network->can_termination);
if (r < 0) {
r = parse_boolean(rvalue);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to parse CAN termination value, ignoring: %s", rvalue);
return 0;
}
network->can_termination = r ? CAN_TERMINATION_DEFAULT_OHM_VALUE : 0;
}
network->can_termination_set = true;
return 0;
}

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <linux/can/netlink.h>
#include "sd-netlink.h"
#include "conf-parser.h"
@ -10,3 +12,7 @@ typedef struct Link Link;
int can_set_netlink_message(Link *link, sd_netlink_message *m);
CONFIG_PARSER_PROTOTYPE(config_parse_can_bitrate);
CONFIG_PARSER_PROTOTYPE(config_parse_can_time_quanta);
CONFIG_PARSER_PROTOTYPE(config_parse_can_restart_usec);
CONFIG_PARSER_PROTOTYPE(config_parse_can_control_mode);
CONFIG_PARSER_PROTOTYPE(config_parse_can_termination);

View File

@ -460,16 +460,17 @@ int config_parse_section_route_table(
return 0;
}
int config_parse_iaid(const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int config_parse_iaid(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
Network *network = userdata;
uint32_t iaid;

View File

@ -992,6 +992,12 @@ static int dhcp4_request_address(Link *link, bool announce) {
addr->route_metric = link->network->dhcp_route_metric;
addr->duplicate_address_detection = link->network->dhcp_send_decline ? ADDRESS_FAMILY_IPV4 : ADDRESS_FAMILY_NO;
if (link->network->dhcp_label) {
addr->label = strdup(link->network->dhcp_label);
if (!addr->label)
return log_oom();
}
if (address_get(link, addr, NULL) < 0)
link->dhcp4_configured = false;
@ -1838,7 +1844,8 @@ int config_parse_dhcp_ip_service_type(
return 0;
}
int config_parse_dhcp_fallback_lease_lifetime(const char *unit,
int config_parse_dhcp_fallback_lease_lifetime(
const char *unit,
const char *filename,
unsigned line,
const char *section,
@ -1848,6 +1855,7 @@ int config_parse_dhcp_fallback_lease_lifetime(const char *unit,
const char *rvalue,
void *data,
void *userdata) {
Network *network = userdata;
uint32_t k;
@ -1876,6 +1884,39 @@ int config_parse_dhcp_fallback_lease_lifetime(const char *unit,
return 0;
}
int config_parse_dhcp_label(
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
char **label = data;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
if (isempty(rvalue)) {
*label = mfree(*label);
return 0;
}
if (!address_label_valid(rvalue)) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Address label is too long or invalid, ignoring assignment: %s", rvalue);
return 0;
}
return free_and_strdup_warn(label, rvalue);
}
static const char* const dhcp_client_identifier_table[_DHCP_CLIENT_ID_MAX] = {
[DHCP_CLIENT_ID_MAC] = "mac",
[DHCP_CLIENT_ID_DUID] = "duid",

View File

@ -33,3 +33,4 @@ CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_max_attempts);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_ip_service_type);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_mud_url);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_fallback_lease_lifetime);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_label);

View File

@ -212,6 +212,7 @@ DHCPv4.RequestOptions, config_parse_dhcp_request_options,
DHCPv4.Anonymize, config_parse_bool, 0, offsetof(Network, dhcp_anonymize)
DHCPv4.SendHostname, config_parse_bool, 0, offsetof(Network, dhcp_send_hostname)
DHCPv4.Hostname, config_parse_hostname, 0, offsetof(Network, dhcp_hostname)
DHCPv4.Label, config_parse_dhcp_label, 0, offsetof(Network, dhcp_label)
DHCPv4.RequestBroadcast, config_parse_tristate, 0, offsetof(Network, dhcp_broadcast)
DHCPv4.VendorClassIdentifier, config_parse_string, 0, offsetof(Network, dhcp_vendor_class_identifier)
DHCPv4.MUDURL, config_parse_mud_url, 0, offsetof(Network, dhcp_mudurl)
@ -346,15 +347,29 @@ IPv6RoutePrefix.LifetimeSec, config_parse_route_prefix_lifetime,
LLDP.MUDURL, config_parse_mud_url, 0, offsetof(Network, lldp_mud)
CAN.BitRate, config_parse_can_bitrate, 0, offsetof(Network, can_bitrate)
CAN.SamplePoint, config_parse_permille, 0, offsetof(Network, can_sample_point)
CAN.TimeQuantaNSec, config_parse_can_time_quanta, 0, offsetof(Network, can_time_quanta_ns)
CAN.PropagationSegment, config_parse_uint32, 0, offsetof(Network, can_propagation_segment)
CAN.PhaseBufferSegment1, config_parse_uint32, 0, offsetof(Network, can_phase_buffer_segment_1)
CAN.PhaseBufferSegment2, config_parse_uint32, 0, offsetof(Network, can_phase_buffer_segment_2)
CAN.SyncJumpWidth, config_parse_uint32, 0, offsetof(Network, can_sync_jump_width)
CAN.DataBitRate, config_parse_can_bitrate, 0, offsetof(Network, can_data_bitrate)
CAN.DataSamplePoint, config_parse_permille, 0, offsetof(Network, can_data_sample_point)
CAN.FDMode, config_parse_tristate, 0, offsetof(Network, can_fd_mode)
CAN.FDNonISO, config_parse_tristate, 0, offsetof(Network, can_non_iso)
CAN.RestartSec, config_parse_sec, 0, offsetof(Network, can_restart_us)
CAN.TripleSampling, config_parse_tristate, 0, offsetof(Network, can_triple_sampling)
CAN.BusErrorReporting, config_parse_tristate, 0, offsetof(Network, can_berr_reporting)
CAN.Termination, config_parse_tristate, 0, offsetof(Network, can_termination)
CAN.ListenOnly, config_parse_tristate, 0, offsetof(Network, can_listen_only)
CAN.DataTimeQuantaNSec, config_parse_can_time_quanta, 0, offsetof(Network, can_data_time_quanta_ns)
CAN.DataPropagationSegment, config_parse_uint32, 0, offsetof(Network, can_data_propagation_segment)
CAN.DataPhaseBufferSegment1, config_parse_uint32, 0, offsetof(Network, can_data_phase_buffer_segment_1)
CAN.DataPhaseBufferSegment2, config_parse_uint32, 0, offsetof(Network, can_data_phase_buffer_segment_2)
CAN.DataSyncJumpWidth, config_parse_uint32, 0, offsetof(Network, can_data_sync_jump_width)
CAN.RestartSec, config_parse_can_restart_usec, 0, offsetof(Network, can_restart_us)
CAN.Loopback, config_parse_can_control_mode, CAN_CTRLMODE_LOOPBACK, 0
CAN.ListenOnly, config_parse_can_control_mode, CAN_CTRLMODE_LISTENONLY, 0
CAN.TripleSampling, config_parse_can_control_mode, CAN_CTRLMODE_3_SAMPLES, 0
CAN.OneShot, config_parse_can_control_mode, CAN_CTRLMODE_ONE_SHOT, 0
CAN.BusErrorReporting, config_parse_can_control_mode, CAN_CTRLMODE_BERR_REPORTING, 0
CAN.FDMode, config_parse_can_control_mode, CAN_CTRLMODE_FD, 0
CAN.PresumeACK, config_parse_can_control_mode, CAN_CTRLMODE_PRESUME_ACK, 0
CAN.FDNonISO, config_parse_can_control_mode, CAN_CTRLMODE_FD_NON_ISO, 0
CAN.ClassicDataLengthCode, config_parse_can_control_mode, CAN_CTRLMODE_CC_LEN8_DLC, 0
CAN.Termination, config_parse_can_termination, 0, 0
QDisc.Parent, config_parse_qdisc_parent, _QDISC_KIND_INVALID, 0
QDisc.Handle, config_parse_qdisc_handle, _QDISC_KIND_INVALID, 0
BFIFO.Parent, config_parse_qdisc_parent, QDISC_KIND_BFIFO, 0

View File

@ -413,12 +413,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
.ipv6_accept_ra_route_metric = DHCP_ROUTE_METRIC,
.ipv6_accept_ra_start_dhcp6_client = IPV6_ACCEPT_RA_START_DHCP6_CLIENT_YES,
.can_triple_sampling = -1,
.can_berr_reporting = -1,
.can_termination = -1,
.can_listen_only = -1,
.can_fd_mode = -1,
.can_non_iso = -1,
};
r = config_parse_many(
@ -585,6 +580,7 @@ static Network *network_free(Network *network) {
free(network->dhcp_mudurl);
strv_free(network->dhcp_user_class);
free(network->dhcp_hostname);
free(network->dhcp_label);
set_free(network->dhcp_deny_listed_ip);
set_free(network->dhcp_allow_listed_ip);
set_free(network->dhcp_request_options);
@ -719,7 +715,8 @@ bool network_has_static_ipv6_configurations(Network *network) {
return false;
}
int config_parse_stacked_netdev(const char *unit,
int config_parse_stacked_netdev(
const char *unit,
const char *filename,
unsigned line,
const char *section,
@ -729,6 +726,7 @@ int config_parse_stacked_netdev(const char *unit,
const char *rvalue,
void *data,
void *userdata) {
_cleanup_free_ char *name = NULL;
NetDevKind kind = ltype;
Hashmap **h = data;
@ -859,26 +857,26 @@ int config_parse_hostname(
void *data,
void *userdata) {
_cleanup_free_ char *hn = NULL;
char **hostname = data;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(hostname);
assert(data);
r = config_parse_string(unit, filename, line, section, section_line, lvalue, ltype, rvalue, &hn, userdata);
if (r < 0)
return r;
if (isempty(rvalue)) {
*hostname = mfree(*hostname);
return 0;
}
if (!hostname_is_valid(hn, 0)) {
if (!hostname_is_valid(rvalue, 0)) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Hostname is not valid, ignoring assignment: %s", rvalue);
return 0;
}
r = dns_name_is_valid(hn);
r = dns_name_is_valid(rvalue);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to check validity of hostname '%s', ignoring assignment: %m", rvalue);
@ -890,7 +888,7 @@ int config_parse_hostname(
return 0;
}
return free_and_replace(*hostname, hn);
return free_and_strdup_warn(hostname, rvalue);
}
int config_parse_timezone(
@ -905,26 +903,27 @@ int config_parse_timezone(
void *data,
void *userdata) {
_cleanup_free_ char *tz = NULL;
char **datap = data;
char **tz = data;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(datap);
assert(data);
r = config_parse_string(unit, filename, line, section, section_line, lvalue, ltype, rvalue, &tz, userdata);
if (r < 0)
return r;
if (isempty(rvalue)) {
*tz = mfree(*tz);
return 0;
}
if (!timezone_is_valid(tz, LOG_WARNING)) {
log_syntax(unit, LOG_WARNING, filename, line, 0,
r = verify_timezone(rvalue, LOG_WARNING);
if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r,
"Timezone is not valid, ignoring assignment: %s", rvalue);
return 0;
}
return free_and_replace(*datap, tz);
return free_and_strdup_warn(tz, rvalue);
}
int config_parse_dns(

View File

@ -129,6 +129,7 @@ struct Network {
char *dhcp_mudurl;
char **dhcp_user_class;
char *dhcp_hostname;
char *dhcp_label;
uint64_t dhcp_max_attempts;
uint32_t dhcp_route_metric;
bool dhcp_route_metric_set;
@ -265,15 +266,23 @@ struct Network {
/* CAN support */
uint32_t can_bitrate;
unsigned can_sample_point;
nsec_t can_time_quanta_ns;
uint32_t can_propagation_segment;
uint32_t can_phase_buffer_segment_1;
uint32_t can_phase_buffer_segment_2;
uint32_t can_sync_jump_width;
uint32_t can_data_bitrate;
unsigned can_data_sample_point;
nsec_t can_data_time_quanta_ns;
uint32_t can_data_propagation_segment;
uint32_t can_data_phase_buffer_segment_1;
uint32_t can_data_phase_buffer_segment_2;
uint32_t can_data_sync_jump_width;
usec_t can_restart_us;
int can_triple_sampling;
int can_berr_reporting;
int can_termination;
int can_listen_only;
int can_fd_mode;
int can_non_iso;
uint32_t can_control_mode_mask;
uint32_t can_control_mode_flags;
uint16_t can_termination;
bool can_termination_set;
/* sysctl settings */
AddressFamily ip_forward;

View File

@ -107,6 +107,7 @@ VendorClassIdentifier=
Hostname=
DUIDType=
UseHostname=
Label=
CriticalConnection=
DUIDRawData=
RequestBroadcast=
@ -257,8 +258,18 @@ MUDURL=
[CAN]
SamplePoint=
BitRate=
TimeQuantaNSec=
PropagationSegment=
PhaseBufferSegment1=
PhaseBufferSegment2=
SyncJumpWidth=
DataSamplePoint=
DataBitRate=
DataTimeQuantaNSec=
DataPropagationSegment=
DataPhaseBufferSegment1=
DataPhaseBufferSegment2=
DataSyncJumpWidth=
FDMode=
FDNonISO=
RestartSec=
@ -266,6 +277,10 @@ TripleSampling=
BusErrorReporting=
Termination=
ListenOnly=
Loopback=
OneShot=
PresumeACK=
ClassicDataLengthCode=
[Address]
DuplicateAddressDetection=
AutoJoin=

View File

@ -14,3 +14,4 @@ Hostname=test-hostname
ClientIdentifier=mac
VendorClassIdentifier=SusantVendorTest
RouteTable=211
Label=test-label

View File

@ -4150,6 +4150,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
self.assertRegex(output, '12:34:56:78:9a:bc')
self.assertRegex(output, '192.168.5')
self.assertRegex(output, '1492')
self.assertRegex(output, 'test-label')
print('## ip route show table main dev veth99')
output = check_output('ip route show table main dev veth99')