aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHimbeer <himbeer@disroot.org>2024-09-07 23:20:11 +0200
committerHimbeer <himbeer@disroot.org>2024-09-07 23:25:33 +0200
commita5c0645c15e53c0141174190c0d7c5da1d234917 (patch)
treebddd2afcc1958cc642ca18a12f43acdbeaef31e2 /src
parent304ecd5d4c54f59299724d83e12e5065443011e8 (diff)
Offer carrier0 as VLAN 7 on eth1 (WAN interface)
Many providers require the use of this VLAN tag in order to access their services. My current DSL modem is capable of adding the tag on its own which is why this functionality wasn't implemented in RSDSL. However a GPON-based fiber infrastructure is going to be built soon. These networks generally use PPPoE just like DSL, but many of them use different VLAN tags. In my particular case the ISP is already known and VLAN 7 is correct for both the current and future providers.
Diffstat (limited to 'src')
-rw-r--r--src/main.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 653c2e6..fa381b4 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -29,6 +29,11 @@ const ADDR_B4: Ipv4Addr = Ipv4Addr::new(192, 0, 0, 2);
const LINK_LOCAL: Ipv6Addr = Ipv6Addr::new(0xfe80, 0, 0, 0, 0, 0, 0, 1);
const ULA_TEMPLATE: Ipv6Addr = Ipv6Addr::new(0xfd0b, 0x9272, 0x534e, 0, 0, 0, 0, 1);
+// Many DSL and GPON providers use this value, but some may require modifying
+// this value. Since this is a custom system and potential ISPs are known in
+// advance, robustness is more important than configurability here.
+const VLAN_TAG: u16 = 7;
+
macro_rules! ula {
($subnet:expr) => {{
let mut segments = ULA_TEMPLATE.segments();
@@ -92,6 +97,9 @@ fn main() -> Result<()> {
configure_modem(&conn)?;
println!("[info] config eth1 192.168.1.2/24 (modem)");
+ configure_carrier(&conn)?;
+ println!("[info] config carrier0 eth1.{}", VLAN_TAG);
+
let mut signals = Signals::new([SIGUSR1])?;
for _ in signals.forever() {
configure_wan_logged(&conn);
@@ -150,6 +158,17 @@ fn configure_modem(conn: &Connection) -> Result<()> {
Ok(())
}
+fn configure_carrier(conn: &Connection) -> Result<()> {
+ let vlan_name = String::from("carrier0");
+
+ if !conn.link_exists(vlan_name.clone())? {
+ conn.link_add_vlan(vlan_name.clone(), "eth1".to_string(), VLAN_TAG)?;
+ }
+ conn.link_set(vlan_name.clone(), true)?;
+
+ Ok(())
+}
+
fn configure_wan_logged(conn: &Connection) {
match configure_wan(conn) {
Ok(_) => {}