patches and low-level development discussion
 help / color / mirror / code / Atom feed
blob 23065757bff4370e4243a882e680437aea1de631 937 bytes (raw)
name: vm/sys/net/image/etc/mdev/iface 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 
#!/bin/execlineb -P
# SPDX-License-Identifier: EUPL-1.2+
# SPDX-FileCopyrightText: 2020-2021 Alyssa Ross <hi@alyssa.is>

importas -Si INTERFACE

ifte

{
  # This interface is connected to another VM.

  # The other VM's IP is encoded in the NIC-specific portion of the
  # interface's MAC address.
  backtick -E CLIENT_IP {
    awk -F: "{printf \"100.64.%d.%d\\n\", \"0x\" $5, \"0x\" $6}"
    /sys/class/net/${INTERFACE}/address
  }

  if { ip address add 169.254.0.1/32 dev $INTERFACE }
  if { ip link set $INTERFACE up }
  ip route add $CLIENT_IP dev $INTERFACE
}

{
  if { test $INTERFACE != lo }
  # This is a physical connection to a network device.
  background { s6-rc -bu change connman }
  if { s6-rc -bu change nftables }
  if {
    forx -pE module { nft_counter nft_masq }
    modprobe $module
  }
  nft add rule ip nat postrouting oifname $INTERFACE counter masquerade
}

grep -iq ^02:01: /sys/class/net/${INTERFACE}/address

debug log:

solving 2306575 ...
found 2306575 in https://spectrum-os.org/git/spectrum

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).