]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
Fixed fwmark update without device status change
authorMathias Hall-Andersen <mathias@hall-andersen.dk>
Tue, 9 Jan 2018 16:26:18 +0000 (17:26 +0100)
committerMathias Hall-Andersen <mathias@hall-andersen.dk>
Tue, 9 Jan 2018 16:26:18 +0000 (17:26 +0100)
An update of the fwmark was missing,
when the device was not bought up after the change.

src/tun.go
src/uapi.go

index 54253b4f25dba54080bc770ef4914929940fc0d8..394ba9a58ac22010db9f1adae648e00aac9663b7 100644 (file)
@@ -50,7 +50,9 @@ func (device *Device) RoutineTUNEventReader() {
                                // begin listening for incomming datagrams
                                logInfo.Println("Interface set up")
                                device.tun.isUp.Set(true)
-                               updateBind(device)
+                               if err := updateBind(device); err != nil {
+                                       logInfo.Println("Failed to bind UDP socket:", err)
+                               }
                        }
                }
 
@@ -59,7 +61,9 @@ func (device *Device) RoutineTUNEventReader() {
                                // stop listening for incomming datagrams
                                logInfo.Println("Interface set down")
                                device.tun.isUp.Set(false)
-                               closeBind(device)
+                               if err := closeBind(device); err != nil {
+                                       logInfo.Println("Failed to close UDP socket:", err)
+                               }
                        }
                }
        }
index 155f4833e3125fddc8288ceb86b0e404cf1630d3..673d413b5175ea47820658cd70b33cfba0e2f21c 100644 (file)
@@ -163,6 +163,9 @@ func ipcSetOperation(device *Device, socket *bufio.ReadWriter) *IPCError {
 
                                device.net.mutex.Lock()
                                device.net.fwmark = uint32(fwmark)
+                               if err := device.net.bind.SetMark(fwmark); err != nil {
+                                       logError.Println("Failed to update fwmark:", err)
+                               }
                                device.net.mutex.Unlock()
 
                        case "public_key":