diff --git a/api/loxinlp/nlp.go b/api/loxinlp/nlp.go index 1fa8f6902..3a81cbfcb 100644 --- a/api/loxinlp/nlp.go +++ b/api/loxinlp/nlp.go @@ -258,7 +258,7 @@ func ApplyBFDConfig() bool { } func applyRoutes(name string) { - tk.LogIt(tk.LogDebug, "[NLP] Applying Route Config for %s \n", name) + tk.LogIt(tk.LogDebug, "nlp: Applying Route Config for %s \n", name) command := "loxicmd apply --per-intf " + name + " -r -c " + opt.Opts.ConfigPath + "/ipconfig/" cmd := exec.Command("bash", "-c", command) output, err := cmd.Output() @@ -281,13 +281,13 @@ func applyConfigMap(name string, state bool, add bool) { if _, ok := nNl.IMap[name]; ok { configApplied = nNl.IMap[name].configApplied if !nNl.IMap[name].configApplied { - tk.LogIt(tk.LogDebug, "[NLP] Applying Config for %s \n", name) + tk.LogIt(tk.LogDebug, "nlp: Applying Config for %s \n", name) if applyAllConfig(name) { configApplied = true - tk.LogIt(tk.LogDebug, "[NLP] Applied Config for %s \n", name) + tk.LogIt(tk.LogDebug, "nlp: Applied Config for %s \n", name) } else { configApplied = false - tk.LogIt(tk.LogError, "[NLP] Applied Config for %s - FAILED\n", name) + tk.LogIt(tk.LogError, "nlp: Applied Config for %s - FAILED\n", name) } nNl.IMap[name] = Intf{dev: name, state: state, configApplied: configApplied, needRouteApply: false} } else if nNl.IMap[name].state != state { @@ -297,19 +297,19 @@ func applyConfigMap(name string, state bool, add bool) { needRouteApply = false } else if !state { needRouteApply = true - tk.LogIt(tk.LogDebug, "[NLP] Route Config for %s will be tried\n", name) + tk.LogIt(tk.LogDebug, "nlp: Route Config for %s will be tried\n", name) } nNl.IMap[name] = Intf{dev: name, state: state, configApplied: configApplied, needRouteApply: needRouteApply} } - tk.LogIt(tk.LogDebug, "[NLP] ConfigMap for %s : %v \n", name, nNl.IMap[name]) + tk.LogIt(tk.LogDebug, "nlp: ConfigMap for %s : %v \n", name, nNl.IMap[name]) } else { - tk.LogIt(tk.LogDebug, "[NLP] Applying Config for %s \n", name) + tk.LogIt(tk.LogDebug, "nlp: Applying Config for %s \n", name) if applyAllConfig(name) { configApplied = true - tk.LogIt(tk.LogDebug, "[NLP] Applied Config for %s \n", name) + tk.LogIt(tk.LogDebug, "nlp: Applied Config for %s \n", name) } else { configApplied = false - tk.LogIt(tk.LogError, "[NLP] Applied Config for %s - FAILED\n", name) + tk.LogIt(tk.LogError, "nlp: Applied Config for %s - FAILED\n", name) } nNl.IMap[name] = Intf{dev: name, state: state, configApplied: configApplied} } @@ -322,12 +322,12 @@ func AddFDBNoHook(macAddress, ifName string) int { var ret int MacAddress, err := net.ParseMAC(macAddress) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] MacAddress Parse %s Fail\n", macAddress) + tk.LogIt(tk.LogWarning, "nlp: MacAddress Parse %s Fail\n", macAddress) return -1 } IfName, err := nlp.LinkByName(ifName) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] Port %s find Fail\n", ifName) + tk.LogIt(tk.LogWarning, "nlp: Port %s find Fail\n", ifName) return -1 } @@ -342,7 +342,7 @@ func AddFDBNoHook(macAddress, ifName string) int { err = nlp.NeighAppend(&neigh) if err != nil { fmt.Printf("err.Error(): %v\n", err.Error()) - tk.LogIt(tk.LogWarning, "[NLP] FDB added Fail\n") + tk.LogIt(tk.LogWarning, "nlp: FDB added Fail\n") return -1 } return ret @@ -352,12 +352,12 @@ func DelFDBNoHook(macAddress, ifName string) int { var ret int MacAddress, err := net.ParseMAC(macAddress) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] MacAddress Parse %s Fail\n", macAddress) + tk.LogIt(tk.LogWarning, "nlp: MacAddress Parse %s Fail\n", macAddress) return -1 } IfName, err := nlp.LinkByName(ifName) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] Port %s find Fail\n", ifName) + tk.LogIt(tk.LogWarning, "nlp: Port %s find Fail\n", ifName) return -1 } @@ -371,7 +371,7 @@ func DelFDBNoHook(macAddress, ifName string) int { } err = nlp.NeighDel(&neigh) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] FDB delete Fail\n") + tk.LogIt(tk.LogWarning, "nlp: FDB delete Fail\n") return -1 } return ret @@ -383,12 +383,12 @@ func AddNeighNoHook(address, ifName, macAddress string) int { IfName, err := nlp.LinkByName(ifName) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] Port %s find Fail\n", ifName) + tk.LogIt(tk.LogWarning, "nlp: Port %s find Fail\n", ifName) return -1 } MacAddress, err := net.ParseMAC(macAddress) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] MacAddress Parse %s Fail\n", macAddress) + tk.LogIt(tk.LogWarning, "nlp: MacAddress Parse %s Fail\n", macAddress) return -1 } // Make Neigh @@ -401,7 +401,7 @@ func AddNeighNoHook(address, ifName, macAddress string) int { err = nlp.NeighAdd(&neigh) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] Neighbor added Fail\n") + tk.LogIt(tk.LogWarning, "nlp: Neighbor added Fail\n") return -1 } return ret @@ -414,7 +414,7 @@ func DelNeighNoHook(address, ifName string) int { if err != nil { nList, err1 := nlp.NeighList(0, 0) if err1 != nil { - tk.LogIt(tk.LogWarning, "[NLP] Neighbor List get Failed\n") + tk.LogIt(tk.LogWarning, "nlp: Neighbor List get Failed\n") return -1 } for _, n := range nList { @@ -432,7 +432,7 @@ func DelNeighNoHook(address, ifName string) int { } err = nlp.NeighDel(&neigh) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] Neighbor delete Fail\n") + tk.LogIt(tk.LogWarning, "nlp: Neighbor delete Fail\n") return -1 } return ret @@ -452,7 +452,7 @@ func AddVLANNoHook(vlanid int) int { }, } if err := nlp.LinkAdd(newBr); err != nil { - tk.LogIt(tk.LogWarning, "[NLP] Vlan Bridge added Fail\n") + tk.LogIt(tk.LogWarning, "nlp: Vlan Bridge added Fail\n") ret = -1 } nlp.LinkSetUp(newBr) @@ -466,17 +466,17 @@ func DelVLANNoHook(vlanid int) int { vlanLink, err := nlp.LinkByName(VlanName) if err != nil { ret = -1 - tk.LogIt(tk.LogWarning, "[NLP] Vlan Bridge get Fail: %s\n", err.Error()) + tk.LogIt(tk.LogWarning, "nlp: Vlan Bridge get Fail: %s\n", err.Error()) } err = nlp.LinkSetDown(vlanLink) if err != nil { ret = -1 - tk.LogIt(tk.LogWarning, "[NLP] Vlan Bridge Link Down Fail: %s\n", err.Error()) + tk.LogIt(tk.LogWarning, "nlp: Vlan Bridge Link Down Fail: %s\n", err.Error()) } err = nlp.LinkDel(vlanLink) if err != nil { ret = -1 - tk.LogIt(tk.LogWarning, "[NLP] Vlan Bridge delete Fail: %s\n", err.Error()) + tk.LogIt(tk.LogWarning, "nlp: Vlan Bridge delete Fail: %s\n", err.Error()) } return ret @@ -489,12 +489,12 @@ func AddVLANMemberNoHook(vlanid int, intfName string, tagged bool) int { VlanBridgeName := fmt.Sprintf("vlan%d", vlanid) VlanLink, err := nlp.LinkByName(VlanBridgeName) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] Vlan Bridge finding Fail\n") + tk.LogIt(tk.LogWarning, "nlp: Vlan Bridge finding Fail\n") return 404 } ParentInterface, err := nlp.LinkByName(intfName) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] Parent interface finding Fail\n") + tk.LogIt(tk.LogWarning, "nlp: Parent interface finding Fail\n") return 404 } if tagged { @@ -531,12 +531,12 @@ func DelVLANMemberNoHook(vlanid int, intfName string, tagged bool) int { VlanName := fmt.Sprintf("vlan%d", vlanid) _, err := nlp.LinkByName(VlanName) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] Vlan Bridge finding Fail\n") + tk.LogIt(tk.LogWarning, "nlp: Vlan Bridge finding Fail\n") return 404 } _, err = nlp.LinkByName(intfName) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] Parent interface finding Fail\n") + tk.LogIt(tk.LogWarning, "nlp: Parent interface finding Fail\n") return 404 } if tagged { @@ -546,12 +546,12 @@ func DelVLANMemberNoHook(vlanid int, intfName string, tagged bool) int { } VlanDevNonPointer, err := nlp.LinkByName(VlanDevName) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] Vlan interface finding Fail\n") + tk.LogIt(tk.LogWarning, "nlp: Vlan interface finding Fail\n") return 404 } err = nlp.LinkSetNoMaster(VlanDevNonPointer) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] No master fail \n") + tk.LogIt(tk.LogWarning, "nlp: No master fail \n") } if tagged { nlp.LinkDel(VlanDevNonPointer) @@ -568,12 +568,12 @@ func AddVxLANBridgeNoHook(vxlanid int, epIntfName string) int { EndpointInterface, err := nlp.LinkByName(epIntfName) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] Endpoint interface finding Fail\n") + tk.LogIt(tk.LogWarning, "nlp: Endpoint interface finding Fail\n") return 404 } LocalIPs, err := nlp.AddrList(EndpointInterface, nlp.FAMILY_V4) if err != nil || len(LocalIPs) == 0 { - tk.LogIt(tk.LogWarning, "[NLP] Endpoint interface dosen't have Local IP address\n") + tk.LogIt(tk.LogWarning, "nlp: Endpoint interface dosen't have Local IP address\n") return 403 } VxlanDev := &nlp.Vxlan{ @@ -593,13 +593,13 @@ func AddVxLANBridgeNoHook(vxlanid int, epIntfName string) int { time.Sleep(1 * time.Second) VxlanDevNonPointer, err := nlp.LinkByName(VxlanBridgeName) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] Vxlan Interface create fail: %s\n", err.Error()) + tk.LogIt(tk.LogWarning, "nlp: Vxlan Interface create fail: %s\n", err.Error()) return -1 } nlp.LinkSetUp(VxlanDevNonPointer) } else { - tk.LogIt(tk.LogWarning, "[NLP] Vxlan Bridge Already exists\n") + tk.LogIt(tk.LogWarning, "nlp: Vxlan Bridge Already exists\n") return 409 } @@ -612,17 +612,17 @@ func DelVxLANNoHook(vxlanid int) int { vxlanLink, err := nlp.LinkByName(VxlanName) if err != nil { ret = -1 - tk.LogIt(tk.LogWarning, "[NLP] Vxlan Bridge get Fail:%s\n", err.Error()) + tk.LogIt(tk.LogWarning, "nlp: Vxlan Bridge get Fail:%s\n", err.Error()) } err = nlp.LinkSetDown(vxlanLink) if err != nil { ret = -1 - tk.LogIt(tk.LogWarning, "[NLP] Vxlan Bridge Link Down Fail:%s\n", err.Error()) + tk.LogIt(tk.LogWarning, "nlp: Vxlan Bridge Link Down Fail:%s\n", err.Error()) } err = nlp.LinkDel(vxlanLink) if err != nil { ret = -1 - tk.LogIt(tk.LogWarning, "[NLP] Vxlan Bridge delete Fail:%s\n", err.Error()) + tk.LogIt(tk.LogWarning, "nlp: Vxlan Bridge delete Fail:%s\n", err.Error()) } return ret @@ -632,7 +632,7 @@ func GetVxLANPeerNoHook() (map[int][]string, error) { ret := map[int][]string{} links, err := nlp.LinkList() if err != nil { - tk.LogIt(tk.LogError, "[NLP] Error in getting device info(%v)\n", err) + tk.LogIt(tk.LogError, "nlp: Error in getting device info(%v)\n", err) return nil, err } @@ -640,7 +640,7 @@ func GetVxLANPeerNoHook() (map[int][]string, error) { if link.Type() == "vxlan" { neighs, err := nlp.NeighList(link.Attrs().Index, unix.AF_BRIDGE) if err != nil { - tk.LogIt(tk.LogError, "[NLP] Error getting neighbors list %v for intf %s\n", + tk.LogIt(tk.LogError, "nlp: Error getting neighbors list %v for intf %s\n", err, link.Attrs().Name) return nil, err } @@ -658,7 +658,7 @@ func GetFDBNoHook() ([]map[string]string, error) { ret := []map[string]string{} links, err := nlp.LinkList() if err != nil { - tk.LogIt(tk.LogError, "[NLP] Error in getting device info(%v)\n", err) + tk.LogIt(tk.LogError, "nlp: Error in getting device info(%v)\n", err) return nil, err } @@ -666,7 +666,7 @@ func GetFDBNoHook() ([]map[string]string, error) { if link.Attrs().MasterIndex > 0 { fdbs, err := nlp.NeighList(link.Attrs().Index, unix.AF_BRIDGE) if err != nil { - tk.LogIt(tk.LogError, "[NLP] Error getting fdb list %v for intf %s\n", + tk.LogIt(tk.LogError, "nlp: Error getting fdb list %v for intf %s\n", err, link.Attrs().Name) return nil, err } @@ -687,7 +687,7 @@ func AddVxLANPeerNoHook(vxlanid int, PeerIP string) int { ifName := fmt.Sprintf("vxlan%d", vxlanid) IfName, err := nlp.LinkByName(ifName) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] VxLAN %s find Fail\n", ifName) + tk.LogIt(tk.LogWarning, "nlp: VxLAN %s find Fail\n", ifName) return -1 } peerIP := net.ParseIP(PeerIP) @@ -703,7 +703,7 @@ func AddVxLANPeerNoHook(vxlanid int, PeerIP string) int { err = nlp.NeighAppend(&Peer) if err != nil { fmt.Printf("err.Error(): %v\n", err.Error()) - tk.LogIt(tk.LogWarning, "[NLP] VxLAN Peer added Fail\n") + tk.LogIt(tk.LogWarning, "nlp: VxLAN Peer added Fail\n") return -1 } return ret @@ -715,7 +715,7 @@ func DelVxLANPeerNoHook(vxlanid int, PeerIP string) int { ifName := fmt.Sprintf("vxlan%d", vxlanid) IfName, err := nlp.LinkByName(ifName) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] VxLAN %s find Fail\n", ifName) + tk.LogIt(tk.LogWarning, "nlp: VxLAN %s find Fail\n", ifName) return -1 } peerIP := net.ParseIP(PeerIP) @@ -731,7 +731,7 @@ func DelVxLANPeerNoHook(vxlanid int, PeerIP string) int { err = nlp.NeighDel(&Peer) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] VxLAN Peer delete Fail\n") + tk.LogIt(tk.LogWarning, "nlp: VxLAN Peer delete Fail\n") return -1 } return ret @@ -762,7 +762,7 @@ func ModLink(link nlp.Link, add bool) int { } else { mod = "DELETE" } - tk.LogIt(tk.LogDebug, "[NLP] %s Device %v mac(%v) attrs(%v) info recvd\n", mod, name, ifMac, attrs) + tk.LogIt(tk.LogDebug, "nlp: %s dev %v mac(%v) attrs(%v) - info recvd\n", mod, name, ifMac, attrs) if _, ok := link.(*nlp.Bridge); ok { @@ -783,10 +783,11 @@ func ModLink(link nlp.Link, add bool) int { } if err != nil { - tk.LogIt(tk.LogInfo, "[NLP] Bridge %v, %d, %v, %v, %v %s failed\n", name, vid, ifMac, state, mtu, mod) - fmt.Println(err) + if !strings.Contains(err.Error(), "exists") { + tk.LogIt(tk.LogInfo, "nlp: Bridge %v, %d, %v, %v, %v %s failed (%s)\n", name, vid, ifMac, state, mtu, mod, err) + } } else { - tk.LogIt(tk.LogInfo, "[NLP] Bridge %v, %d, %v, %v, %v %s [OK]\n", name, vid, ifMac, state, mtu, mod) + tk.LogIt(tk.LogInfo, "nlp: Bridge %v, %d, %v, %v, %v %s [OK]\n", name, vid, ifMac, state, mtu, mod) } if (add && (err != nil)) || !add { @@ -825,10 +826,10 @@ func ModLink(link nlp.Link, add bool) int { ret, err = hooks.NetVlanPortDel(&cmn.VlanPortMod{Vid: vid, Dev: pname[0], Tagged: true}) } if err != nil { - tk.LogIt(tk.LogError, "[NLP] TVlan Port %v, v(%v), %v, %v, %v %s failed\n", name, vid, ifMac, state, mtu, mod) + tk.LogIt(tk.LogError, "nlp: TVlan Port %v, v(%v), %v, %v, %v %s failed\n", name, vid, ifMac, state, mtu, mod) fmt.Println(err) } else { - tk.LogIt(tk.LogInfo, "[NLP] TVlan Port %v, v(%v), %v, %v, %v %s OK\n", name, vid, ifMac, state, mtu, mod) + tk.LogIt(tk.LogInfo, "nlp: TVlan Port %v, v(%v), %v, %v, %v %s OK\n", name, vid, ifMac, state, mtu, mod) } applyConfigMap(name, state, add) return ret @@ -868,10 +869,10 @@ func ModLink(link nlp.Link, add bool) int { return -1 } real = uif.Attrs().Name - tk.LogIt(tk.LogInfo, "[NLP] Port %v, uif %v %s\n", name, real, mod) + tk.LogIt(tk.LogInfo, "nlp: Port %v, uif %v %s\n", name, real, mod) } else if _, ok := link.(*nlp.Bond); ok { pType = cmn.PortBond - tk.LogIt(tk.LogInfo, "[NLP] Bond %v, %s\n", name, mod) + tk.LogIt(tk.LogInfo, "nlp: Bond %v, %s\n", name, mod) } else if iptun, ok := link.(*nlp.Iptun); ok { pType = cmn.PortIPTun if iptun.Remote == nil || iptun.Local == nil { @@ -884,7 +885,7 @@ func ModLink(link nlp.Link, add bool) int { tunId = 1 // Just needed internally tunDst = iptun.Remote tunSrc = iptun.Local - tk.LogIt(tk.LogInfo, "[NLP] IPTun %v (%s:%s), %s\n", name, tunSrc.String(), tunDst.String(), mod) + tk.LogIt(tk.LogInfo, "nlp: IPTun %v (%s:%s), %s\n", name, tunSrc.String(), tunDst.String(), mod) } else if vtiTun, ok := link.(*nlp.Vti); ok { pType = cmn.PortVti if vtiTun.Remote == nil || vtiTun.Local == nil { @@ -897,7 +898,7 @@ func ModLink(link nlp.Link, add bool) int { tunId = int(vtiTun.OKey) tunDst = vtiTun.Remote tunSrc = vtiTun.Local - tk.LogIt(tk.LogInfo, "[NLP] VTITun %v (%s:%s), %s\n", name, tunSrc.String(), tunDst.String(), mod) + tk.LogIt(tk.LogInfo, "nlp: VTITun %v (%s:%s), %s\n", name, tunSrc.String(), tunDst.String(), mod) } else if master != "" { pType = cmn.PortBondSif } @@ -908,18 +909,18 @@ func ModLink(link nlp.Link, add bool) int { TunID: tunId, TunDst: tunDst, TunSrc: tunSrc}) if err != nil { if !strings.Contains(err.Error(), "port exists") { - tk.LogIt(tk.LogError, "[NLP] Port %v, %v, %v, %v add failed\n", name, ifMac, state, mtu) + tk.LogIt(tk.LogError, "nlp: Port %v, %v, %v, %v add failed (%s)\n", name, ifMac, state, mtu, err) } } else { - tk.LogIt(tk.LogInfo, "[NLP] Port %v, %v, %v, %v add [OK]\n", name, ifMac, state, mtu) + tk.LogIt(tk.LogInfo, "nlp: Port %v, %v, %v, %v add [OK]\n", name, ifMac, state, mtu) } applyConfigMap(name, state, add) } else if attrs.MasterIndex == 0 { ret, err = hooks.NetPortDel(&cmn.PortMod{Dev: name, Ptype: pType}) if err != nil { - tk.LogIt(tk.LogError, "[NLP] Port %v, %v, %v, %v delete failed\n", name, ifMac, state, mtu) + tk.LogIt(tk.LogError, "nlp: Port %v, %v, %v, %v delete failed (%s)\n", name, ifMac, state, mtu, err) } else { - tk.LogIt(tk.LogInfo, "[NLP] Port %v, %v, %v, %v delete [OK]\n", name, ifMac, state, mtu) + tk.LogIt(tk.LogInfo, "nlp: Port %v, %v, %v, %v delete [OK]\n", name, ifMac, state, mtu) } applyConfigMap(name, state, add) @@ -934,10 +935,10 @@ func ModLink(link nlp.Link, add bool) int { ret, err = hooks.NetVlanPortDel(&cmn.VlanPortMod{Vid: vid, Dev: name, Tagged: false}) } if err != nil { - tk.LogIt(tk.LogError, "[NLP] Vlan(%v) Port %v, %v, %v, %v %s failed\n", vid, name, ifMac, state, mtu, mod) + tk.LogIt(tk.LogError, "nlp: Vlan(%v) Port %v, %v, %v, %v %s failed\n", vid, name, ifMac, state, mtu, mod) fmt.Println(err) } else { - tk.LogIt(tk.LogInfo, "[NLP] Vlan(%v) Port %v, %v, %v, %v %s [OK]\n", vid, name, ifMac, state, mtu, mod) + tk.LogIt(tk.LogInfo, "nlp: Vlan(%v) Port %v, %v, %v, %v %s [OK]\n", vid, name, ifMac, state, mtu, mod) } if (add && (err != nil)) || !add { applyConfigMap(name, state, add) @@ -955,10 +956,10 @@ func AddAddr(addr nlp.Addr, link nlp.Link) int { ret, err := hooks.NetAddrAdd(&cmn.IPAddrMod{Dev: name, IP: ipStr}) if err != nil { - tk.LogIt(tk.LogError, "[NLP] IPv4 Address %v Port %v failed %v\n", ipStr, name, err) + tk.LogIt(tk.LogError, "nlp: IPv4 Address %v Port %v failed %v\n", ipStr, name, err) ret = -1 } else { - tk.LogIt(tk.LogInfo, "[NLP] IPv4 Address %v Port %v added\n", ipStr, name) + tk.LogIt(tk.LogInfo, "nlp: IPv4 Address %v Port %v added\n", ipStr, name) } return ret } @@ -969,19 +970,19 @@ func AddAddrNoHook(address, ifName string) int { if err != nil { _, err := hooks.NetAddrAdd(&cmn.IPAddrMod{Dev: ifName, IP: address}) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] Hook IPv4 Address %v Port %v Add Fail\n", address, ifName) + tk.LogIt(tk.LogWarning, "nlp: Hook IPv4 Address %v Port %v Add Fail\n", address, ifName) return -1 } return 0 } Address, err := nlp.ParseAddr(address) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] IPv4 Address %s Parse Fail\n", address) + tk.LogIt(tk.LogWarning, "nlp: IPv4 Address %s Parse Fail\n", address) return -1 } err = nlp.AddrAdd(IfName, Address) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] IPv4 Address %v Port %v added Fail\n", address, ifName) + tk.LogIt(tk.LogWarning, "nlp: IPv4 Address %v Port %v added Fail\n", address, ifName) return -1 } return ret @@ -993,19 +994,19 @@ func DelAddrNoHook(address, ifName string) int { if err != nil { _, err := hooks.NetAddrDel(&cmn.IPAddrMod{Dev: ifName, IP: address}) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] Hook IPv4 Address %v Port %v delete Fail\n", address, ifName) + tk.LogIt(tk.LogWarning, "nlp: Hook IPv4 Address %v Port %v delete Fail\n", address, ifName) return -1 } return 0 } Address, err := nlp.ParseAddr(address) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] IPv4 Address %s Parse Fail\n", address) + tk.LogIt(tk.LogWarning, "nlp: IPv4 Address %s Parse Fail\n", address) return -1 } err = nlp.AddrDel(IfName, Address) if err != nil { - tk.LogIt(tk.LogWarning, "[NLP] IPv4 Address %v Port %v delete Fail\n", address, ifName) + tk.LogIt(tk.LogWarning, "nlp: IPv4 Address %v Port %v delete Fail\n", address, ifName) return -1 } return ret @@ -1043,11 +1044,11 @@ func AddNeigh(neigh nlp.Neigh, link nlp.Link) int { State: neigh.State, HardwareAddr: neigh.HardwareAddr}) if err != nil { - tk.LogIt(tk.LogError, "[NLP] NH %v mac %v dev %v add failed %v\n", neigh.IP.String(), mac, + tk.LogIt(tk.LogError, "nlp: NH %v mac %v dev %v add failed %v\n", neigh.IP.String(), mac, name, err) } /*else { - tk.LogIt(tk.LogInfo, "[NLP] NH %v mac %v dev %v added\n", neigh.IP.String(), mac, name) + tk.LogIt(tk.LogInfo, "nlp: NH %v mac %v dev %v added\n", neigh.IP.String(), mac, name) } */ } else if neigh.Family == unix.AF_BRIDGE { if neigh.Vlan == 1 { @@ -1082,7 +1083,7 @@ func AddNeigh(neigh nlp.Neigh, link nlp.Link) int { brId = vxlan.VxlanId ftype = cmn.FdbTun } else { - tk.LogIt(tk.LogInfo, "[NLP] L2fdb %v brId %v dst %v dev %v IGNORED\n", mac[:], brId, dst, name) + tk.LogIt(tk.LogInfo, "nlp: L2fdb %v brId %v dst %v dev %v IGNORED\n", mac[:], brId, dst, name) return 0 } } else { @@ -1093,9 +1094,9 @@ func AddNeigh(neigh nlp.Neigh, link nlp.Link) int { ret, err = hooks.NetFdbAdd(&cmn.FdbMod{MacAddr: mac, BridgeID: brId, Dev: name, Dst: dst, Type: ftype}) if err != nil { - tk.LogIt(tk.LogError, "[NLP] L2fdb %v brId %v dst %v dev %v add failed\n", mac[:], brId, dst, name) + tk.LogIt(tk.LogError, "nlp: L2fdb %v brId %v dst %v dev %v add failed\n", mac[:], brId, dst, name) } else { - tk.LogIt(tk.LogInfo, "[NLP] L2fdb %v brId %v dst %v dev %v added\n", mac[:], brId, dst, name) + tk.LogIt(tk.LogInfo, "nlp: L2fdb %v brId %v dst %v dev %v added\n", mac[:], brId, dst, name) } } @@ -1120,10 +1121,10 @@ func DelNeigh(neigh nlp.Neigh, link nlp.Link) int { ret, err = hooks.NetNeighDel(&cmn.NeighMod{IP: neigh.IP}) if err != nil { - tk.LogIt(tk.LogError, "[NLP] NH %v %v del failed\n", neigh.IP.String(), name) + tk.LogIt(tk.LogError, "nlp: NH %v %v del failed\n", neigh.IP.String(), name) ret = -1 } else { - tk.LogIt(tk.LogInfo, "[NLP] NH %v %v deleted\n", neigh.IP.String(), name) + tk.LogIt(tk.LogInfo, "nlp: NH %v %v deleted\n", neigh.IP.String(), name) } } else { @@ -1176,10 +1177,10 @@ func DelNeigh(neigh nlp.Neigh, link nlp.Link) int { ret, err = hooks.NetFdbDel(&cmn.FdbMod{MacAddr: mac, BridgeID: brId}) if err != nil { - tk.LogIt(tk.LogError, "[NLP] L2fdb %v brId %v dst %s dev %v delete failed %v\n", mac[:], brId, dst, name, err) + tk.LogIt(tk.LogError, "nlp: L2fdb %v brId %v dst %s dev %v delete failed %v\n", mac[:], brId, dst, name, err) ret = -1 } else { - tk.LogIt(tk.LogInfo, "[NLP] L2fdb %v brId %v dst %s dev %v deleted\n", mac[:], brId, dst, name) + tk.LogIt(tk.LogInfo, "nlp: L2fdb %v brId %v dst %s dev %v deleted\n", mac[:], brId, dst, name) } } return ret @@ -1219,17 +1220,17 @@ func AddRoute(route nlp.Route) int { ret, err := hooks.NetRouteAdd(&cmn.RouteMod{Protocol: int(route.Protocol), Flags: route.Flags, Dst: ipNet, GWs: gws}) if err != nil { if route.Gw != nil { - tk.LogIt(tk.LogError, "[NLP] RT %s via %s proto %d add failed-%s\n", ipNet.String(), + tk.LogIt(tk.LogError, "nlp: RT %s via %s proto %d add failed-%s\n", ipNet.String(), route.Gw.String(), route.Protocol, err) } else { - tk.LogIt(tk.LogError, "[NLP] RT %s add failed-%s\n", ipNet.String(), err) + tk.LogIt(tk.LogError, "nlp: RT %s add failed-%s\n", ipNet.String(), err) } } else { if route.Gw != nil { - tk.LogIt(tk.LogInfo, "[NLP] RT %s via %s added\n", ipNet.String(), + tk.LogIt(tk.LogInfo, "nlp: RT %s via %s added\n", ipNet.String(), route.Gw.String()) } else { - tk.LogIt(tk.LogInfo, "[NLP] RT %s added\n", ipNet.String()) + tk.LogIt(tk.LogInfo, "nlp: RT %s added\n", ipNet.String()) } } @@ -1286,17 +1287,17 @@ func DelRoute(route nlp.Route) int { ret, err := hooks.NetRouteDel(&cmn.RouteMod{Dst: ipNet}) if err != nil { if route.Gw != nil { - tk.LogIt(tk.LogError, "[NLP] RT %s via %s delete failed-%s\n", ipNet.String(), + tk.LogIt(tk.LogError, "nlp: RT %s via %s delete failed-%s\n", ipNet.String(), route.Gw.String(), err) } else { - tk.LogIt(tk.LogError, "[NLP] RT %s delete failed-%s\n", ipNet.String(), err) + tk.LogIt(tk.LogError, "nlp: RT %s delete failed-%s\n", ipNet.String(), err) } } else { if route.Gw != nil { - tk.LogIt(tk.LogInfo, "[NLP] RT %s via %s deleted\n", ipNet.String(), + tk.LogIt(tk.LogInfo, "nlp: RT %s via %s deleted\n", ipNet.String(), route.Gw.String()) } else { - tk.LogIt(tk.LogInfo, "[NLP] RT %s deleted\n", ipNet.String()) + tk.LogIt(tk.LogInfo, "nlp: RT %s deleted\n", ipNet.String()) } } return ret @@ -1330,19 +1331,19 @@ func AUWorkSingle(m nlp.AddrUpdate) int { if m.NewAddr { _, err := hooks.NetAddrAdd(&cmn.IPAddrMod{Dev: name, IP: m.LinkAddress.String()}) if err != nil { - tk.LogIt(tk.LogInfo, "[NLP] Address %v Port %v add failed\n", m.LinkAddress.String(), name) + tk.LogIt(tk.LogInfo, "nlp: Address %v Port %v add failed\n", m.LinkAddress.String(), name) fmt.Println(err) } else { - tk.LogIt(tk.LogInfo, "[NLP] Address %v Port %v added\n", m.LinkAddress.String(), name) + tk.LogIt(tk.LogInfo, "nlp: Address %v Port %v added\n", m.LinkAddress.String(), name) } } else { _, err := hooks.NetAddrDel(&cmn.IPAddrMod{Dev: name, IP: m.LinkAddress.String()}) if err != nil { - tk.LogIt(tk.LogInfo, "[NLP] Address %v Port %v delete failed\n", m.LinkAddress.String(), name) + tk.LogIt(tk.LogInfo, "nlp: Address %v Port %v delete failed\n", m.LinkAddress.String(), name) fmt.Println(err) } else { - tk.LogIt(tk.LogInfo, "[NLP] Address %v Port %v deleted\n", m.LinkAddress.String(), name) + tk.LogIt(tk.LogInfo, "nlp: Address %v Port %v deleted\n", m.LinkAddress.String(), name) } } @@ -1512,13 +1513,13 @@ func GetBridges() { func NlpGet(ch chan bool) int { var ret int - tk.LogIt(tk.LogInfo, "[NLP] Getting device info\n") + tk.LogIt(tk.LogInfo, "nlp: Getting device info\n") GetBridges() links, err := nlp.LinkList() if err != nil { - tk.LogIt(tk.LogError, "[NLP] Error in getting device info(%v)\n", err) + tk.LogIt(tk.LogError, "nlp: Error in getting device info(%v)\n", err) ret = -1 } @@ -1540,12 +1541,12 @@ func NlpGet(ch chan bool) int { // Need addresss to work with addrs, err := nlp.AddrList(link, nlp.FAMILY_ALL) if err != nil { - tk.LogIt(tk.LogError, "[NLP] Error getting address list %v for intf %s\n", + tk.LogIt(tk.LogError, "nlp: Error getting address list %v for intf %s\n", err, link.Attrs().Name) } if len(addrs) == 0 { - tk.LogIt(tk.LogDebug, "[NLP] No addresses found for intf %s\n", link.Attrs().Name) + tk.LogIt(tk.LogDebug, "nlp: No addresses found for intf %s\n", link.Attrs().Name) } else { for _, addr := range addrs { AddAddr(addr, link) @@ -1559,12 +1560,12 @@ func NlpGet(ch chan bool) int { if link.Attrs().MasterIndex > 0 || ok { neighs, err := nlp.NeighList(link.Attrs().Index, unix.AF_BRIDGE) if err != nil { - tk.LogIt(tk.LogError, "[NLP] Error getting neighbors list %v for intf %s\n", + tk.LogIt(tk.LogError, "nlp: Error getting neighbors list %v for intf %s\n", err, link.Attrs().Name) } if len(neighs) == 0 { - tk.LogIt(tk.LogDebug, "[NLP] No FDBs found for intf %s\n", link.Attrs().Name) + tk.LogIt(tk.LogDebug, "nlp: No FDBs found for intf %s\n", link.Attrs().Name) } else { for _, neigh := range neighs { AddNeigh(neigh, link) @@ -1574,12 +1575,12 @@ func NlpGet(ch chan bool) int { addrs, err := nlp.AddrList(link, nlp.FAMILY_ALL) if err != nil { - tk.LogIt(tk.LogError, "[NLP] Error getting address list %v for intf %s\n", + tk.LogIt(tk.LogError, "nlp: Error getting address list %v for intf %s\n", err, link.Attrs().Name) } if len(addrs) == 0 { - tk.LogIt(tk.LogDebug, "[NLP] No addresses found for intf %s\n", link.Attrs().Name) + tk.LogIt(tk.LogDebug, "nlp: No addresses found for intf %s\n", link.Attrs().Name) } else { for _, addr := range addrs { AddAddr(addr, link) @@ -1588,12 +1589,12 @@ func NlpGet(ch chan bool) int { neighs, err := nlp.NeighList(link.Attrs().Index, nlp.FAMILY_ALL) if err != nil { - tk.LogIt(tk.LogError, "[NLP] Error getting neighbors list %v for intf %s\n", + tk.LogIt(tk.LogError, "nlp: Error getting neighbors list %v for intf %s\n", err, link.Attrs().Name) } if len(neighs) == 0 { - tk.LogIt(tk.LogDebug, "[NLP] No neighbors found for intf %s\n", link.Attrs().Name) + tk.LogIt(tk.LogDebug, "nlp: No neighbors found for intf %s\n", link.Attrs().Name) } else { for _, neigh := range neighs { AddNeigh(neigh, link) @@ -1604,11 +1605,11 @@ func NlpGet(ch chan bool) int { /* Get Routes */ routes, err := nlp.RouteList(nil, nlp.FAMILY_ALL) if err != nil { - tk.LogIt(tk.LogError, "[NLP] Error getting route list %v\n", err) + tk.LogIt(tk.LogError, "nlp: Error getting route list %v\n", err) } if len(routes) == 0 { - tk.LogIt(tk.LogDebug, "[NLP] No STATIC routes found\n") + tk.LogIt(tk.LogDebug, "nlp: No STATIC routes found\n") } else { for _, route := range routes { var m nlp.RouteUpdate @@ -1623,7 +1624,7 @@ func NlpGet(ch chan bool) int { RUWorkSingle(m) } } - tk.LogIt(tk.LogInfo, "[NLP] nlp get done\n") + tk.LogIt(tk.LogInfo, "nlp: nlp get done\n") ch <- true return ret } @@ -1636,48 +1637,48 @@ func LbSessionGet(done bool) int { if _, err := os.Stat(opt.Opts.ConfigPath + "/EPconfig.txt"); errors.Is(err, os.ErrNotExist) { if err != nil { - tk.LogIt(tk.LogInfo, "[NLP] Continuing without EP config file: %s\n", err.Error()) + tk.LogIt(tk.LogInfo, "nlp: Continuing without EP config file: %s\n", err.Error()) } } else { applyEPConfig() } - tk.LogIt(tk.LogInfo, "[NLP] EndPoint config process done\n") + tk.LogIt(tk.LogInfo, "nlp: EndPoint config process done\n") if _, err := os.Stat(opt.Opts.ConfigPath + "/lbconfig.txt"); errors.Is(err, os.ErrNotExist) { if err != nil { - tk.LogIt(tk.LogInfo, "[NLP] Continuing without LB config file : %s \n", err.Error()) + tk.LogIt(tk.LogInfo, "nlp: Continuing without LB config file : %s \n", err.Error()) } } else { applyLoadBalancerConfig() } - tk.LogIt(tk.LogInfo, "[NLP] LoadBalancer config done\n") + tk.LogIt(tk.LogInfo, "nlp: LoadBalancer config done\n") if _, err := os.Stat(opt.Opts.ConfigPath + "/sessionconfig.txt"); errors.Is(err, os.ErrNotExist) { if err != nil { - tk.LogIt(tk.LogInfo, "[NLP] Continuing without Session config file : %s \n", err.Error()) + tk.LogIt(tk.LogInfo, "nlp: Continuing without Session config file : %s \n", err.Error()) } } else { applySessionConfig() } - tk.LogIt(tk.LogInfo, "[NLP] Session config done\n") + tk.LogIt(tk.LogInfo, "nlp: Session config done\n") if _, err := os.Stat(opt.Opts.ConfigPath + "/sessionulclconfig.txt"); errors.Is(err, os.ErrNotExist) { if err != nil { - tk.LogIt(tk.LogInfo, "[NLP] Continuing without UlCl config file : %s \n", err.Error()) + tk.LogIt(tk.LogInfo, "nlp: Continuing without UlCl config file : %s \n", err.Error()) } } else { applyUlClConfig() } - tk.LogIt(tk.LogInfo, "[NLP] Session UlCl config done\n") + tk.LogIt(tk.LogInfo, "nlp: Session UlCl config done\n") if _, err := os.Stat(opt.Opts.ConfigPath + "/FWconfig.txt"); errors.Is(err, os.ErrNotExist) { if err != nil { - tk.LogIt(tk.LogInfo, "[NLP] Continuing without Firewall config file : %s \n", err.Error()) + tk.LogIt(tk.LogInfo, "nlp: Continuing without Firewall config file : %s \n", err.Error()) } } else { applyFWConfig() } - tk.LogIt(tk.LogInfo, "[NLP] Firewall config done\n") + tk.LogIt(tk.LogInfo, "nlp: Firewall config done\n") } return 0 @@ -1700,7 +1701,7 @@ func NlpInit(bgpPeerMode bool, blackList, whitelist string, ipvsCompat bool) *Nl if err != nil { fmt.Println(err) } else { - tk.LogIt(tk.LogInfo, "[NLP] Route msgs subscribed\n") + tk.LogIt(tk.LogInfo, "nlp: Route msgs subscribed\n") } go NLWorker(nNl, bgpPeerMode, checkInit, waitInit) @@ -1725,28 +1726,28 @@ func NlpInit(bgpPeerMode bool, blackList, whitelist string, ipvsCompat bool) *Nl if err != nil { tk.LogIt(tk.LogError, "%v", err) } else { - tk.LogIt(tk.LogInfo, "[NLP] Link msgs subscribed\n") + tk.LogIt(tk.LogInfo, "nlp: Link msgs subscribed\n") } err = nlp.AddrSubscribe(nNl.FromAUCh, nNl.FromAUDone) if err != nil { fmt.Println(err) } else { - tk.LogIt(tk.LogInfo, "[NLP] Addr msgs subscribed\n") + tk.LogIt(tk.LogInfo, "nlp: Addr msgs subscribed\n") } err = nlp.NeighSubscribe(nNl.FromNUCh, nNl.FromNUDone) if err != nil { fmt.Println(err) } else { - tk.LogIt(tk.LogInfo, "[NLP] Neigh msgs subscribed\n") + tk.LogIt(tk.LogInfo, "nlp: Neigh msgs subscribed\n") } err = nlp.RouteSubscribe(nNl.FromRUCh, nNl.FromRUDone) if err != nil { fmt.Println(err) } else { - tk.LogIt(tk.LogInfo, "[NLP] Route msgs subscribed\n") + tk.LogIt(tk.LogInfo, "nlp: Route msgs subscribed\n") } - tk.LogIt(tk.LogInfo, "[NLP] NLP Subscription done\n") + tk.LogIt(tk.LogInfo, "nlp: NLP Subscription done\n") go NlpGet(checkInit) done := <-checkInit diff --git a/api/restapi/handler/cluster.go b/api/restapi/handler/cluster.go index ab8ef3a1d..28927fe11 100644 --- a/api/restapi/handler/cluster.go +++ b/api/restapi/handler/cluster.go @@ -16,21 +16,22 @@ package handler import ( + "net" + "github.com/go-openapi/runtime/middleware" "github.com/loxilb-io/loxilb/api/models" "github.com/loxilb-io/loxilb/api/restapi/operations" cmn "github.com/loxilb-io/loxilb/common" tk "github.com/loxilb-io/loxilib" - "net" ) func ConfigGetCIState(params operations.GetConfigCistateAllParams) middleware.Responder { var result []*models.CIStatusGetEntry result = make([]*models.CIStatusGetEntry, 0) - tk.LogIt(tk.LogDebug, "[API] Status %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Status %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) hasMod, err := ApiHooks.NetCIStateGet() if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } for _, h := range hasMod { @@ -45,7 +46,7 @@ func ConfigGetCIState(params operations.GetConfigCistateAllParams) middleware.Re } func ConfigPostCIState(params operations.PostConfigCistateParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] HA %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: HA %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var hasMod cmn.HASMod @@ -53,11 +54,11 @@ func ConfigPostCIState(params operations.PostConfigCistateParams) middleware.Res hasMod.Instance = params.Attr.Instance hasMod.State = params.Attr.State hasMod.Vip = net.ParseIP(params.Attr.Vip) - tk.LogIt(tk.LogDebug, "[API] Instance %s New HA State : %v, VIP: %s\n", + tk.LogIt(tk.LogDebug, "api: Instance %s New HA State : %v, VIP: %s\n", hasMod.Instance, hasMod.State, hasMod.Vip) _, err := ApiHooks.NetCIStateMod(&hasMod) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} @@ -66,10 +67,10 @@ func ConfigPostCIState(params operations.PostConfigCistateParams) middleware.Res func ConfigGetBFDSession(params operations.GetConfigBfdAllParams) middleware.Responder { var result []*models.BfdGetEntry result = make([]*models.BfdGetEntry, 0) - tk.LogIt(tk.LogDebug, "[API] Status %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Status %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) bfdMod, err := ApiHooks.NetBFDGet() if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } for _, h := range bfdMod { @@ -89,7 +90,7 @@ func ConfigGetBFDSession(params operations.GetConfigBfdAllParams) middleware.Res } func ConfigPostBFDSession(params operations.PostConfigBfdParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] HA %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: HA %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var bfdMod cmn.BFDMod @@ -100,18 +101,18 @@ func ConfigPostBFDSession(params operations.PostConfigBfdParams) middleware.Resp bfdMod.Interval = params.Attr.Interval bfdMod.RetryCount = params.Attr.RetryCount - tk.LogIt(tk.LogDebug, "[API] Instance %s BFD session add : %s, Interval: %d, RetryCount: %d\n", + tk.LogIt(tk.LogDebug, "api: Instance %s BFD session add : %s, Interval: %d, RetryCount: %d\n", bfdMod.Instance, bfdMod.RemoteIP, bfdMod.Interval, bfdMod.RetryCount) _, err := ApiHooks.NetBFDAdd(&bfdMod) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} } func ConfigDeleteBFDSession(params operations.DeleteConfigBfdRemoteIPRemoteIPParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] HA %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: HA %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var bfdMod cmn.BFDMod @@ -122,11 +123,11 @@ func ConfigDeleteBFDSession(params operations.DeleteConfigBfdRemoteIPRemoteIPPar bfdMod.RemoteIP = net.ParseIP(params.RemoteIP) - tk.LogIt(tk.LogDebug, "[API] Instance %s BFD session delete : %s\n", + tk.LogIt(tk.LogDebug, "api: Instance %s BFD session delete : %s\n", bfdMod.Instance, bfdMod.RemoteIP) _, err := ApiHooks.NetBFDDel(&bfdMod) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} diff --git a/api/restapi/handler/conntrack.go b/api/restapi/handler/conntrack.go index 9a36e5c3a..b121deca7 100644 --- a/api/restapi/handler/conntrack.go +++ b/api/restapi/handler/conntrack.go @@ -24,11 +24,11 @@ import ( ) func ConfigGetConntrack(params operations.GetConfigConntrackAllParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Conntrack %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Conntrack %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) // Get Conntrack informations res, err := ApiHooks.NetCtInfoGet() if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } var result []*models.ConntrackEntry diff --git a/api/restapi/handler/endpoint.go b/api/restapi/handler/endpoint.go index 9571a22c0..3707c839f 100644 --- a/api/restapi/handler/endpoint.go +++ b/api/restapi/handler/endpoint.go @@ -25,11 +25,11 @@ import ( func ConfigGetEndPoint(params operations.GetConfigEndpointAllParams) middleware.Responder { // Get endpoint rules - tk.LogIt(tk.LogDebug, "[API] EndPoint %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: EndPoint %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) res, err := ApiHooks.NetEpHostGet() if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error : %v\n", err) return &ResultResponse{Result: err.Error()} } var result []*models.EndPointGetEntry @@ -58,7 +58,7 @@ func ConfigGetEndPoint(params operations.GetConfigEndpointAllParams) middleware. } func ConfigPostEndPoint(params operations.PostConfigEndpointParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] EndPoint %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: EndPoint %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) EP := cmn.EndPointMod{} EP.HostName = params.Attr.HostName @@ -78,7 +78,7 @@ func ConfigPostEndPoint(params operations.PostConfigEndpointParams) middleware.R } func ConfigDeleteEndPoint(params operations.DeleteConfigEndpointEpipaddressIPAddressParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] EndPoint %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: EndPoint %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) EP := cmn.EndPointMod{} EP.HostName = params.IPAddress diff --git a/api/restapi/handler/fdb.go b/api/restapi/handler/fdb.go index 1f16ea3e1..ffcd33cf9 100644 --- a/api/restapi/handler/fdb.go +++ b/api/restapi/handler/fdb.go @@ -24,7 +24,7 @@ import ( ) func ConfigPostFDB(params operations.PostConfigFdbParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] FDB %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: FDB %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) ret := loxinlp.AddFDBNoHook(params.Attr.MacAddress, params.Attr.Dev) if ret != 0 { return &ResultResponse{Result: "fail"} @@ -33,7 +33,7 @@ func ConfigPostFDB(params operations.PostConfigFdbParams) middleware.Responder { } func ConfigDeleteFDB(params operations.DeleteConfigFdbMacAddressDevIfNameParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] FDB %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: FDB %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) ret := loxinlp.DelFDBNoHook(params.MacAddress, params.IfName) if ret != 0 { return &ResultResponse{Result: "fail"} @@ -42,7 +42,7 @@ func ConfigDeleteFDB(params operations.DeleteConfigFdbMacAddressDevIfNameParams) } func ConfigGetFDB(params operations.GetConfigFdbAllParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] FDB %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: FDB %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) fdbs, _ := loxinlp.GetFDBNoHook() var result []*models.FDBEntry result = make([]*models.FDBEntry, 0) diff --git a/api/restapi/handler/firewall.go b/api/restapi/handler/firewall.go index 7899694b7..8a128fd2b 100644 --- a/api/restapi/handler/firewall.go +++ b/api/restapi/handler/firewall.go @@ -26,7 +26,7 @@ import ( ) func ConfigPostFW(params operations.PostConfigFirewallParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Firewall %s API called by IP: %s. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.RemoteAddr, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Firewall %s API called by IP: %s. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.RemoteAddr, params.HTTPRequest.URL) Opts := cmn.FwOptArg{} Rules := cmn.FwRuleArg{} FW := cmn.FwRuleMod{} @@ -80,7 +80,7 @@ func ConfigPostFW(params operations.PostConfigFirewallParams) middleware.Respond } func ConfigDeleteFW(params operations.DeleteConfigFirewallParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Firewall %s API called by IP: %s. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.RemoteAddr, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Firewall %s API called by IP: %s. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.RemoteAddr, params.HTTPRequest.URL) Rules := cmn.FwRuleArg{} FW := cmn.FwRuleMod{} @@ -144,7 +144,7 @@ func ConfigDeleteFW(params operations.DeleteConfigFirewallParams) middleware.Res } func ConfigGetFW(params operations.GetConfigFirewallAllParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Firewall %s API called by IP: %s. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.RemoteAddr, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Firewall %s API called by IP: %s. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.RemoteAddr, params.HTTPRequest.URL) res, _ := ApiHooks.NetFwRuleGet() var result []*models.FirewallEntry result = make([]*models.FirewallEntry, 0) diff --git a/api/restapi/handler/gobgp.go b/api/restapi/handler/gobgp.go index 47bfc65f3..ccd00498a 100644 --- a/api/restapi/handler/gobgp.go +++ b/api/restapi/handler/gobgp.go @@ -26,10 +26,10 @@ import ( ) func ConfigGetBGPNeigh(params operations.GetConfigBgpNeighAllParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] BGP Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: BGP Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) res, err := ApiHooks.NetGoBGPNeighGet() if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } var result []*models.BGPNeighGetEntry @@ -47,7 +47,7 @@ func ConfigGetBGPNeigh(params operations.GetConfigBgpNeighAllParams) middleware. return operations.NewGetConfigBgpNeighAllOK().WithPayload(&operations.GetConfigBgpNeighAllOKBody{BgpNeiAttr: result}) } func ConfigPostBGPNeigh(params operations.PostConfigBgpNeighParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] BGP Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: BGP Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var bgpNeighMod cmn.GoBGPNeighMod // IP address @@ -62,17 +62,17 @@ func ConfigPostBGPNeigh(params operations.PostConfigBgpNeighParams) middleware.R // Multi-hop or not bgpNeighMod.MultiHop = params.Attr.SetMultiHop - tk.LogIt(tk.LogDebug, "[API] GoBGP neighAdd : %v\n", bgpNeighMod) + tk.LogIt(tk.LogDebug, "api: GoBGP neighAdd : %v\n", bgpNeighMod) _, err := ApiHooks.NetGoBGPNeighAdd(&bgpNeighMod) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} } func ConfigDeleteBGPNeigh(params operations.DeleteConfigBgpNeighIPAddressParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] BGP Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: BGP Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var bgpNeighMod cmn.GoBGPNeighMod // IP address @@ -81,17 +81,17 @@ func ConfigDeleteBGPNeigh(params operations.DeleteConfigBgpNeighIPAddressParams) // Remote AS bgpNeighMod.RemoteAS = uint32(*params.RemoteAs) - tk.LogIt(tk.LogDebug, "[API] GoBGP neighDel : %v\n", bgpNeighMod) + tk.LogIt(tk.LogDebug, "api: GoBGP neighDel : %v\n", bgpNeighMod) _, err := ApiHooks.NetGoBGPNeighDel(&bgpNeighMod) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} } func ConfigPostBGPGlobal(params operations.PostConfigBgpGlobalParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] BGP Global Config %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: BGP Global Config %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var bgpG cmn.GoBGPGlobalConfig // Router ID @@ -109,17 +109,17 @@ func ConfigPostBGPGlobal(params operations.PostConfigBgpGlobalParams) middleware bgpG.ListenPort = 179 } - tk.LogIt(tk.LogDebug, "[API] GoBGP GCAdd : %v\n", bgpG) + tk.LogIt(tk.LogDebug, "api: GoBGP GCAdd : %v\n", bgpG) _, err := ApiHooks.NetGoBGPGCAdd(&bgpG) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} } func ConfigPostBGPPolicyDefinedsets(params operations.PostConfigBgpPolicyDefinedsetsDefinesetTypeParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] BGP Policy DefinedSet %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: BGP Policy DefinedSet %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var bgpPolicyDefinedSet cmn.GoBGPPolicyDefinedSetMod // name @@ -138,36 +138,36 @@ func ConfigPostBGPPolicyDefinedsets(params operations.PostConfigBgpPolicyDefined bgpPolicyDefinedSet.List = params.Attr.List } - tk.LogIt(tk.LogDebug, "[API] GoBGP bgpPolicyPrefix : %v\n", bgpPolicyDefinedSet) + tk.LogIt(tk.LogDebug, "api: GoBGP bgpPolicyPrefix : %v\n", bgpPolicyDefinedSet) _, err := ApiHooks.NetGoBGPPolicyDefinedSetAdd(&bgpPolicyDefinedSet) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} } func ConfigDeleteBGPPolicyDefinedsets(params operations.DeleteConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] BGP Policy DefinedSet %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: BGP Policy DefinedSet %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var bgpPolicyConfig cmn.GoBGPPolicyDefinedSetMod bgpPolicyConfig.Name = params.TypeName bgpPolicyConfig.DefinedTypeString = params.DefinesetType - tk.LogIt(tk.LogDebug, "[API] GoBGP bgpPolicyConfig : %v\n", bgpPolicyConfig) + tk.LogIt(tk.LogDebug, "api: GoBGP bgpPolicyConfig : %v\n", bgpPolicyConfig) _, err := ApiHooks.NetGoBGPPolicyDefinedSetDel(&bgpPolicyConfig) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} } func ConfigGetBGPPolicyDefinedSetGet(params operations.GetConfigBgpPolicyDefinedsetsDefinesetTypeTypeNameParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] BGP DefinedSet %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: BGP DefinedSet %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) res, err := ApiHooks.NetGoBGPPolicyDefinedSetGet(params.TypeName, params.DefinesetType) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } result := make([]*models.BGPPolicyDefinedSetGetEntry, 0) @@ -194,7 +194,7 @@ func ConfigGetBGPPolicyDefinedSetGet(params operations.GetConfigBgpPolicyDefined } func ConfigPostBGPPolicyDefinitions(params operations.PostConfigBgpPolicyDefinitionsParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] BGP Policy Definitions %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: BGP Policy Definitions %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var bgpPolicyConfig cmn.GoBGPPolicyDefinitionsMod // name @@ -276,36 +276,36 @@ func ConfigPostBGPPolicyDefinitions(params operations.PostConfigBgpPolicyDefinit bgpPolicyConfig.Statement = append(bgpPolicyConfig.Statement, tmpStatement) } - tk.LogIt(tk.LogDebug, "[API] GoBGP bgpPolicyConfig : %v\n", bgpPolicyConfig) + tk.LogIt(tk.LogDebug, "api: GoBGP bgpPolicyConfig : %v\n", bgpPolicyConfig) _, err := ApiHooks.NetGoBGPPolicyDefinitionAdd(&bgpPolicyConfig) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} } func ConfigDeleteBGPPolicyDefinitions(params operations.DeleteConfigBgpPolicyDefinitionsPolicyNameParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] BGP Policy Definitions %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: BGP Policy Definitions %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var bgpPolicyConfig cmn.GoBGPPolicyDefinitionsMod // name bgpPolicyConfig.Name = params.PolicyName - tk.LogIt(tk.LogDebug, "[API] GoBGP bgpPolicyConfig : %v\n", bgpPolicyConfig) + tk.LogIt(tk.LogDebug, "api: GoBGP bgpPolicyConfig : %v\n", bgpPolicyConfig) _, err := ApiHooks.NetGoBGPPolicyDefinitionDel(&bgpPolicyConfig) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} } func ConfigGetBGPPolicyDefinitions(params operations.GetConfigBgpPolicyDefinitionsAllParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] BGP Policy Definitions %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: BGP Policy Definitions %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) res, err := ApiHooks.NetGoBGPPolicyDefinitionsGet() if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } result := make([]*models.BGPPolicyDefinitionsMod, 0) @@ -400,34 +400,34 @@ func ConfigGetBGPPolicyDefinitions(params operations.GetConfigBgpPolicyDefinitio } func ConfigPostBGPPolicyApply(params operations.PostConfigBgpPolicyApplyParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] BGP Policy Apply %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: BGP Policy Apply %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var bgpPolicyConfig cmn.GoBGPPolicyApply bgpPolicyConfig.NeighIPAddress = params.Attr.IPAddress bgpPolicyConfig.PolicyType = params.Attr.PolicyType bgpPolicyConfig.Polices = params.Attr.Policies bgpPolicyConfig.RouteAction = params.Attr.RouteAction - tk.LogIt(tk.LogDebug, "[API] GoBGP bgpPolicyConfig : %v\n", bgpPolicyConfig) + tk.LogIt(tk.LogDebug, "api: GoBGP bgpPolicyConfig : %v\n", bgpPolicyConfig) _, err := ApiHooks.NetGoBGPPolicyApplyAdd(&bgpPolicyConfig) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} } func ConfigDeleteBGPPolicyApply(params operations.DeleteConfigBgpPolicyApplyParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] BGP Policy Apply %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: BGP Policy Apply %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var bgpPolicyConfig cmn.GoBGPPolicyApply bgpPolicyConfig.NeighIPAddress = params.Attr.IPAddress bgpPolicyConfig.PolicyType = params.Attr.PolicyType bgpPolicyConfig.Polices = params.Attr.Policies bgpPolicyConfig.RouteAction = "" // No need RouteAction for delete - tk.LogIt(tk.LogDebug, "[API] GoBGP bgpPolicyConfig : %v\n", bgpPolicyConfig) + tk.LogIt(tk.LogDebug, "api: GoBGP bgpPolicyConfig : %v\n", bgpPolicyConfig) _, err := ApiHooks.NetGoBGPPolicyApplyDel(&bgpPolicyConfig) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} diff --git a/api/restapi/handler/ipv4address.go b/api/restapi/handler/ipv4address.go index a6a87d8eb..79c42edf7 100644 --- a/api/restapi/handler/ipv4address.go +++ b/api/restapi/handler/ipv4address.go @@ -26,7 +26,7 @@ import ( ) func ConfigPostIPv4Address(params operations.PostConfigIpv4addressParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] IPv4 address %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: IPv4 address %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) ret := loxinlp.AddAddrNoHook(params.Attr.IPAddress, params.Attr.Dev) if ret != 0 { return &ResultResponse{Result: "fail"} @@ -35,7 +35,7 @@ func ConfigPostIPv4Address(params operations.PostConfigIpv4addressParams) middle } func ConfigDeleteIPv4Address(params operations.DeleteConfigIpv4addressIPAddressMaskDevIfNameParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] IPv4 address %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: IPv4 address %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) ipNet := fmt.Sprintf("%s/%s", params.IPAddress, params.Mask) ret := loxinlp.DelAddrNoHook(ipNet, params.IfName) if ret != 0 { @@ -45,7 +45,7 @@ func ConfigDeleteIPv4Address(params operations.DeleteConfigIpv4addressIPAddressM } func ConfigGetIPv4Address(params operations.GetConfigIpv4addressAllParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] IPv4 address %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: IPv4 address %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) res, _ := ApiHooks.NetAddrGet() var result []*models.IPV4AddressGetEntry result = make([]*models.IPV4AddressGetEntry, 0) diff --git a/api/restapi/handler/loadbalancer.go b/api/restapi/handler/loadbalancer.go index 585abdfc7..bcc14fbb3 100644 --- a/api/restapi/handler/loadbalancer.go +++ b/api/restapi/handler/loadbalancer.go @@ -24,7 +24,7 @@ import ( ) func ConfigPostLoadbalancer(params operations.PostConfigLoadbalancerParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var lbRules cmn.LbRuleMod @@ -70,17 +70,17 @@ func ConfigPostLoadbalancer(params operations.PostConfigLoadbalancerParams) midd return &ResultResponse{Result: "Error: Only Hash Selection criteria allowed for DSR mode"} } - tk.LogIt(tk.LogDebug, "[API] lbRules : %v\n", lbRules) + tk.LogIt(tk.LogDebug, "api: lbRules : %v\n", lbRules) _, err := ApiHooks.NetLbRuleAdd(&lbRules) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} } func ConfigDeleteLoadbalancer(params operations.DeleteConfigLoadbalancerHosturlHosturlExternalipaddressIPAddressPortPortProtocolProtoParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var lbServ cmn.LbServiceArg var lbRules cmn.LbRuleMod @@ -100,17 +100,17 @@ func ConfigDeleteLoadbalancer(params operations.DeleteConfigLoadbalancerHosturlH } lbRules.Serv = lbServ - tk.LogIt(tk.LogDebug, "[API] lbRules : %v\n", lbRules) + tk.LogIt(tk.LogDebug, "api: lbRules : %v\n", lbRules) _, err := ApiHooks.NetLbRuleDel(&lbRules) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} } func ConfigDeleteLoadbalancerWithoutPath(params operations.DeleteConfigLoadbalancerExternalipaddressIPAddressPortPortProtocolProtoParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var lbServ cmn.LbServiceArg var lbRules cmn.LbRuleMod @@ -126,10 +126,10 @@ func ConfigDeleteLoadbalancerWithoutPath(params operations.DeleteConfigLoadbalan } lbRules.Serv = lbServ - tk.LogIt(tk.LogDebug, "[API] lbRules (w/o Path): %v\n", lbRules) + tk.LogIt(tk.LogDebug, "api: lbRules (w/o Path): %v\n", lbRules) _, err := ApiHooks.NetLbRuleDel(&lbRules) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} @@ -137,11 +137,11 @@ func ConfigDeleteLoadbalancerWithoutPath(params operations.DeleteConfigLoadbalan func ConfigGetLoadbalancer(params operations.GetConfigLoadbalancerAllParams) middleware.Responder { // Get LB rules - tk.LogIt(tk.LogDebug, "[API] Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) res, err := ApiHooks.NetLbRuleGet() if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } var result []*models.LoadbalanceEntry @@ -193,19 +193,19 @@ func ConfigGetLoadbalancer(params operations.GetConfigLoadbalancerAllParams) mid } func ConfigDeleteAllLoadbalancer(params operations.DeleteConfigLoadbalancerAllParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) res, err := ApiHooks.NetLbRuleGet() if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } for _, lbRules := range res { - tk.LogIt(tk.LogDebug, "[API] lbRules : %v\n", lbRules) + tk.LogIt(tk.LogDebug, "api: lbRules : %v\n", lbRules) _, err := ApiHooks.NetLbRuleDel(&lbRules) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) } } @@ -213,11 +213,11 @@ func ConfigDeleteAllLoadbalancer(params operations.DeleteConfigLoadbalancerAllPa } func ConfigDeleteLoadbalancerByName(params operations.DeleteConfigLoadbalancerNameLbNameParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Load balancer %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) res, err := ApiHooks.NetLbRuleGet() if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } for _, lbRules := range res { @@ -226,10 +226,10 @@ func ConfigDeleteLoadbalancerByName(params operations.DeleteConfigLoadbalancerNa continue } - tk.LogIt(tk.LogDebug, "[API] lbRules : %v\n", lbRules) + tk.LogIt(tk.LogDebug, "api: lbRules : %v\n", lbRules) _, err := ApiHooks.NetLbRuleDel(&lbRules) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error : %v\n", err) } } diff --git a/api/restapi/handler/mirror.go b/api/restapi/handler/mirror.go index 1fa09ef30..79c75cc53 100644 --- a/api/restapi/handler/mirror.go +++ b/api/restapi/handler/mirror.go @@ -27,7 +27,7 @@ import ( ) func ConfigPostMirror(params operations.PostConfigMirrorParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Mirror %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Mirror %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var MirrMod cmn.MirrMod @@ -52,35 +52,35 @@ func ConfigPostMirror(params operations.PostConfigMirrorParams) middleware.Respo MirrMod.Target.AttachMent = cmn.MirrObjType(params.Attr.TargetObject.Attachment) } - tk.LogIt(tk.LogDebug, "[API] MirrMod : %v\n", MirrMod) + tk.LogIt(tk.LogDebug, "api: MirrMod : %v\n", MirrMod) _, err := ApiHooks.NetMirrorAdd(&MirrMod) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} } func ConfigDeleteMirror(params operations.DeleteConfigMirrorIdentIdentParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Mirror %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Mirror %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var MirrMod cmn.MirrMod MirrMod.Ident = params.Ident - tk.LogIt(tk.LogDebug, "[API] MirrMod : %v\n", MirrMod) + tk.LogIt(tk.LogDebug, "api: MirrMod : %v\n", MirrMod) _, err := ApiHooks.NetMirrorDel(&MirrMod) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} } func ConfigGetMirror(params operations.GetConfigMirrorAllParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Mirror %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Mirror %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) res, err := ApiHooks.NetMirrorGet() if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } var result []*models.MirrorGetEntry diff --git a/api/restapi/handler/neighbor.go b/api/restapi/handler/neighbor.go index 077221de0..1343e4bb0 100644 --- a/api/restapi/handler/neighbor.go +++ b/api/restapi/handler/neighbor.go @@ -25,7 +25,7 @@ import ( ) func ConfigPostNeighbor(params operations.PostConfigNeighborParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] IPv4 Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: IPv4 Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) ret := loxinlp.AddNeighNoHook(params.Attr.IPAddress, params.Attr.Dev, params.Attr.MacAddress) if ret != 0 { return &ResultResponse{Result: "fail"} @@ -34,7 +34,7 @@ func ConfigPostNeighbor(params operations.PostConfigNeighborParams) middleware.R } func ConfigDeleteNeighbor(params operations.DeleteConfigNeighborIPAddressDevIfNameParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] IPv4 Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: IPv4 Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) ret := loxinlp.DelNeighNoHook(params.IPAddress, params.IfName) if ret != 0 { return &ResultResponse{Result: "fail"} @@ -43,7 +43,7 @@ func ConfigDeleteNeighbor(params operations.DeleteConfigNeighborIPAddressDevIfNa } func ConfigGetNeighbor(params operations.GetConfigNeighborAllParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] IPv4 Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: IPv4 Neighbor %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) res, _ := ApiHooks.NetNeighGet() var result []*models.NeighborEntry result = make([]*models.NeighborEntry, 0) diff --git a/api/restapi/handler/params.go b/api/restapi/handler/params.go index 4b5792694..59e13aa0a 100644 --- a/api/restapi/handler/params.go +++ b/api/restapi/handler/params.go @@ -25,33 +25,33 @@ import ( ) func ConfigPostParams(params operations.PostConfigParamsParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Params %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Params %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var param cmn.ParamMod // Set Param State param.LogLevel = params.Attr.LogLevel - tk.LogIt(tk.LogDebug, "[API] New LogLevel %s\n", param.LogLevel) + tk.LogIt(tk.LogDebug, "api: New LogLevel %s\n", param.LogLevel) _, err := ApiHooks.NetParamSet(param) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} } func ConfigGetParams(params operations.GetConfigParamsParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Status %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Status %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var param cmn.ParamMod var payload models.OperParams // Get Param state _, err := ApiHooks.NetParamGet(¶m) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } payload.LogLevel = param.LogLevel - tk.LogIt(tk.LogDebug, "[API] LogLevel %s\n", param.LogLevel) + tk.LogIt(tk.LogDebug, "api: LogLevel %s\n", param.LogLevel) return operations.NewGetConfigParamsOK().WithPayload(&payload) } diff --git a/api/restapi/handler/policy.go b/api/restapi/handler/policy.go index a2dfaab60..a0d3d5b59 100644 --- a/api/restapi/handler/policy.go +++ b/api/restapi/handler/policy.go @@ -25,7 +25,7 @@ import ( ) func ConfigPostPolicy(params operations.PostConfigPolicyParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Policy %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Policy %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var polMod cmn.PolMod @@ -50,35 +50,35 @@ func ConfigPostPolicy(params operations.PostConfigPolicyParams) middleware.Respo polMod.Target.AttachMent = cmn.PolObjType(params.Attr.TargetObject.Attachment) } - tk.LogIt(tk.LogDebug, "[API] polMod : %v\n", polMod) + tk.LogIt(tk.LogDebug, "api: polMod : %v\n", polMod) _, err := ApiHooks.NetPolicerAdd(&polMod) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} } func ConfigDeletePolicy(params operations.DeleteConfigPolicyIdentIdentParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Policy %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Policy %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var polMod cmn.PolMod polMod.Ident = params.Ident - tk.LogIt(tk.LogDebug, "[API] polMod : %v\n", polMod) + tk.LogIt(tk.LogDebug, "api: polMod : %v\n", polMod) _, err := ApiHooks.NetPolicerDel(&polMod) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} } func ConfigGetPolicy(params operations.GetConfigPolicyAllParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Policy %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Policy %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) res, err := ApiHooks.NetPolicerGet() if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } diff --git a/api/restapi/handler/port.go b/api/restapi/handler/port.go index a14432682..699405a66 100644 --- a/api/restapi/handler/port.go +++ b/api/restapi/handler/port.go @@ -24,12 +24,12 @@ import ( ) func ConfigGetPort(params operations.GetConfigPortAllParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Port %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Port %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) // Get Port informations ports, err := ApiHooks.NetPortGet() if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } var result []*models.PortEntry diff --git a/api/restapi/handler/prometheus.go b/api/restapi/handler/prometheus.go index 603a9a855..0e9585035 100644 --- a/api/restapi/handler/prometheus.go +++ b/api/restapi/handler/prometheus.go @@ -27,7 +27,7 @@ import ( ) func ConfigGetPrometheusCounter(params operations.GetMetricsParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Prometheus %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Prometheus %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) if !options.Opts.Prometheus { return operations.NewGetMetricsOK().WithPayload("Prometheus option is disabled.") } diff --git a/api/restapi/handler/route.go b/api/restapi/handler/route.go index 7d4515f82..c7f7af2ce 100644 --- a/api/restapi/handler/route.go +++ b/api/restapi/handler/route.go @@ -17,38 +17,39 @@ package handler import ( "fmt" + "strconv" + "strings" + "github.com/go-openapi/runtime/middleware" "github.com/loxilb-io/loxilb/api/loxinlp" "github.com/loxilb-io/loxilb/api/models" "github.com/loxilb-io/loxilb/api/restapi/operations" tk "github.com/loxilb-io/loxilib" - "strconv" - "strings" ) func ConfigPostRoute(params operations.PostConfigRouteParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Route %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Route %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) ret := loxinlp.AddRouteNoHook(params.Attr.DestinationIPNet, params.Attr.Gateway, params.Attr.Protocol) if ret != 0 { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", ret) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", ret) return &ResultResponse{Result: "fail"} } return &ResultResponse{Result: "Success"} } func ConfigDeleteRoute(params operations.DeleteConfigRouteDestinationIPNetIPAddressMaskParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Route %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Route %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) DstIP := fmt.Sprintf("%s/%d", params.IPAddress, params.Mask) ret := loxinlp.DelRouteNoHook(DstIP) if ret != 0 { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", ret) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", ret) return &ResultResponse{Result: "fail"} } return &ResultResponse{Result: "Success"} } func ConfigGetRoute(params operations.GetConfigRouteAllParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Route %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Route %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) res, _ := ApiHooks.NetRouteGet() var result []*models.RouteGetEntry result = make([]*models.RouteGetEntry, 0) diff --git a/api/restapi/handler/session.go b/api/restapi/handler/session.go index 33b37e279..854b91eea 100644 --- a/api/restapi/handler/session.go +++ b/api/restapi/handler/session.go @@ -28,7 +28,7 @@ import ( ) func ConfigPostSession(params operations.PostConfigSessionParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Session %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Session %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var sessionMod cmn.SessionMod // Default Setting @@ -41,32 +41,32 @@ func ConfigPostSession(params operations.PostConfigSessionParams) middleware.Res sessionMod.CnTun.TeID = uint32(params.Attr.CoreNetworkTunnel.TeID) sessionMod.CnTun.Addr = net.ParseIP(params.Attr.CoreNetworkTunnel.TunnelIP) - tk.LogIt(tk.LogDebug, "[API] Session sessionMod : %v\n", sessionMod) + tk.LogIt(tk.LogDebug, "api: Session sessionMod : %v\n", sessionMod) _, err := ApiHooks.NetSessionAdd(&sessionMod) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} } func ConfigDeleteSession(params operations.DeleteConfigSessionIdentIdentParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Session %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Session %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var sessionMod cmn.SessionMod // Default Setting sessionMod.Ident = params.Ident - tk.LogIt(tk.LogDebug, "[API] Session sessionMod : %v\n", sessionMod) + tk.LogIt(tk.LogDebug, "api: Session sessionMod : %v\n", sessionMod) _, err := ApiHooks.NetSessionDel(&sessionMod) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} } func ConfigPostSessionUlCl(params operations.PostConfigSessionulclParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Session UlCl %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Session UlCl %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var sessionulclMod cmn.SessionUlClMod // Default Setting @@ -75,17 +75,17 @@ func ConfigPostSessionUlCl(params operations.PostConfigSessionulclParams) middle sessionulclMod.Args.Addr = net.ParseIP(params.Attr.UlclArgument.UlclIP) sessionulclMod.Args.Qfi = uint8(params.Attr.UlclArgument.Qfi) - tk.LogIt(tk.LogDebug, "[API] Session sessionMod : %v\n", sessionulclMod) + tk.LogIt(tk.LogDebug, "api: Session sessionMod : %v\n", sessionulclMod) _, err := ApiHooks.NetSessionUlClAdd(&sessionulclMod) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} } func ConfigDeleteSessionUlCl(params operations.DeleteConfigSessionulclIdentIdentUlclAddressIPAddressParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Session UlCl %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Session UlCl %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) var sessionulclMod cmn.SessionUlClMod @@ -94,10 +94,10 @@ func ConfigDeleteSessionUlCl(params operations.DeleteConfigSessionulclIdentIdent // UlCl Argument setting sessionulclMod.Args.Addr = net.ParseIP(params.IPAddress) - tk.LogIt(tk.LogDebug, "[API] Session sessionMod : %v\n", sessionulclMod) + tk.LogIt(tk.LogDebug, "api: Session sessionMod : %v\n", sessionulclMod) _, err := ApiHooks.NetSessionUlClDel(&sessionulclMod) if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return &ResultResponse{Result: "Success"} @@ -105,11 +105,11 @@ func ConfigDeleteSessionUlCl(params operations.DeleteConfigSessionulclIdentIdent func ConfigGetSession(params operations.GetConfigSessionAllParams) middleware.Responder { // Get Session rules - tk.LogIt(tk.LogDebug, "[API] Session %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Session %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) res, err := ApiHooks.NetSessionGet() if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } var result []*models.SessionEntry @@ -142,11 +142,11 @@ func ConfigGetSession(params operations.GetConfigSessionAllParams) middleware.Re func ConfigGetSessionUlCl(params operations.GetConfigSessionulclAllParams) middleware.Responder { // Get Ulcl rules - tk.LogIt(tk.LogDebug, "[API] Session UlCl %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Session UlCl %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) res, err := ApiHooks.NetSessionUlClGet() if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } var result []*models.SessionUlClEntry diff --git a/api/restapi/handler/status.go b/api/restapi/handler/status.go index 540b8d88c..24c6a3a8c 100644 --- a/api/restapi/handler/status.go +++ b/api/restapi/handler/status.go @@ -24,7 +24,7 @@ import ( ) func ConfigGetProcess(params operations.GetStatusProcessParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Status %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Status %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) //var result []*models.ProcessInfoEntry process := status.ProcessInfoGet() @@ -32,21 +32,21 @@ func ConfigGetProcess(params operations.GetStatusProcessParams) middleware.Respo } func ConfigGetDevice(params operations.GetStatusDeviceParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Status %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Status %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) // Get Conntrack informations res, err := status.DeviceInfoGet() if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return operations.NewGetStatusDeviceOK().WithPayload(res) } func ConfigGetFileSystem(params operations.GetStatusFilesystemParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Status %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Status %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) res, err := status.FileSystemInfoGet() if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } return operations.NewGetStatusFilesystemOK().WithPayload(&operations.GetStatusFilesystemOKBody{FilesystemAttr: res}) diff --git a/api/restapi/handler/vlan.go b/api/restapi/handler/vlan.go index fe831a035..8715f1df5 100644 --- a/api/restapi/handler/vlan.go +++ b/api/restapi/handler/vlan.go @@ -24,7 +24,7 @@ import ( ) func ConfigPostVLAN(params operations.PostConfigVlanParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Vlan %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Vlan %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) ret := loxinlp.AddVLANNoHook(int(params.Attr.Vid)) if ret != 0 { return &ResultResponse{Result: "fail"} @@ -33,7 +33,7 @@ func ConfigPostVLAN(params operations.PostConfigVlanParams) middleware.Responder } func ConfigDeleteVLAN(params operations.DeleteConfigVlanVlanIDParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Vlan %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Vlan %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) ret := loxinlp.DelVLANNoHook(int(params.VlanID)) if ret != 0 { return &ResultResponse{Result: "fail"} @@ -42,7 +42,7 @@ func ConfigDeleteVLAN(params operations.DeleteConfigVlanVlanIDParams) middleware } func ConfigPostVLANMember(params operations.PostConfigVlanVlanIDMemberParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Vlan %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Vlan %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) ret := loxinlp.AddVLANMemberNoHook(int(params.VlanID), params.Attr.Dev, params.Attr.Tagged) if ret != 0 { return &ResultResponse{Result: "fail"} @@ -51,7 +51,7 @@ func ConfigPostVLANMember(params operations.PostConfigVlanVlanIDMemberParams) mi } func ConfigDeleteVLANMember(params operations.DeleteConfigVlanVlanIDMemberIfNameTaggedTaggedParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Vlan %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Vlan %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) ret := loxinlp.DelVLANMemberNoHook(int(params.VlanID), params.IfName, params.Tagged) if ret != 0 { return &ResultResponse{Result: "fail"} @@ -60,7 +60,7 @@ func ConfigDeleteVLANMember(params operations.DeleteConfigVlanVlanIDMemberIfName } func ConfigGetVLAN(params operations.GetConfigVlanAllParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] Vlan %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: Vlan %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) res, _ := ApiHooks.NetVlanGet() var result []*models.VlanGetEntry result = make([]*models.VlanGetEntry, 0) diff --git a/api/restapi/handler/vxlan.go b/api/restapi/handler/vxlan.go index c4a1c002a..58a89d044 100644 --- a/api/restapi/handler/vxlan.go +++ b/api/restapi/handler/vxlan.go @@ -24,7 +24,7 @@ import ( ) func ConfigPostVxLAN(params operations.PostConfigTunnelVxlanParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] VxLAN %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: VxLAN %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) ret := loxinlp.AddVxLANBridgeNoHook(int(params.Attr.VxlanID), params.Attr.EpIntf) if ret != 0 { return &ResultResponse{Result: "fail"} @@ -33,7 +33,7 @@ func ConfigPostVxLAN(params operations.PostConfigTunnelVxlanParams) middleware.R } func ConfigDeleteVxLAN(params operations.DeleteConfigTunnelVxlanVxlanIDParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] VxLAN %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: VxLAN %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) ret := loxinlp.DelVxLANNoHook(int(params.VxlanID)) if ret != 0 { return &ResultResponse{Result: "fail"} @@ -42,7 +42,7 @@ func ConfigDeleteVxLAN(params operations.DeleteConfigTunnelVxlanVxlanIDParams) m } func ConfigPostVxLANPeer(params operations.PostConfigTunnelVxlanVxlanIDPeerParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] VxLAN %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: VxLAN %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) ret := loxinlp.AddVxLANPeerNoHook(int(params.VxlanID), params.Attr.PeerIP) if ret != 0 { return &ResultResponse{Result: "fail"} @@ -51,7 +51,7 @@ func ConfigPostVxLANPeer(params operations.PostConfigTunnelVxlanVxlanIDPeerParam } func ConfigDeleteVxLANPeer(params operations.DeleteConfigTunnelVxlanVxlanIDPeerPeerIPParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] VxLAN %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: VxLAN %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) ret := loxinlp.DelVxLANPeerNoHook(int(params.VxlanID), params.PeerIP) if ret != 0 { return &ResultResponse{Result: "fail"} @@ -60,12 +60,12 @@ func ConfigDeleteVxLANPeer(params operations.DeleteConfigTunnelVxlanVxlanIDPeerP } func ConfigGetVxLAN(params operations.GetConfigTunnelVxlanAllParams) middleware.Responder { - tk.LogIt(tk.LogDebug, "[API] VxLAN %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) + tk.LogIt(tk.LogDebug, "api: VxLAN %s API called. url : %s\n", params.HTTPRequest.Method, params.HTTPRequest.URL) peers, _ := loxinlp.GetVxLANPeerNoHook() ports, err := ApiHooks.NetPortGet() if err != nil { - tk.LogIt(tk.LogDebug, "[API] Error occur : %v\n", err) + tk.LogIt(tk.LogDebug, "api: Error occur : %v\n", err) return &ResultResponse{Result: err.Error()} } var result []*models.VxlanEntry diff --git a/pkg/loxinet/apiclient.go b/pkg/loxinet/apiclient.go index 5c6feb4df..a93815a45 100644 --- a/pkg/loxinet/apiclient.go +++ b/pkg/loxinet/apiclient.go @@ -123,6 +123,7 @@ func (na *NetAPIStruct) NetVlanAdd(vm *cmn.VlanMod) (int, error) { PortHwInfo{vm.MacAddr, vm.Link, vm.State, vm.Mtu, "", "", vm.TunID, nil, nil}) if ret == VlanExistsErr { ret = 0 + err = nil } return ret, err diff --git a/pkg/loxinet/layer3.go b/pkg/loxinet/layer3.go index a1e9bf9d7..d859a352d 100644 --- a/pkg/loxinet/layer3.go +++ b/pkg/loxinet/layer3.go @@ -50,6 +50,7 @@ type Ifa struct { Key IfaKey Zone *Zone Sync DpStatusT + Addr [6]byte Ifas []*IfaEnt } @@ -524,7 +525,7 @@ func (l3 *L3H) IfaGet() []cmn.IPAddrGet { } // IfaTicker - Periodic ticker for checking Ifas -func (l3 *L3H) IfasTicker() { +func (l3 *L3H) IfasTicker(fsync bool) { for _, ifa := range l3.IfaMap { if ifa.Key.Obj == "lo" { continue @@ -538,8 +539,8 @@ func (l3 *L3H) IfasTicker() { canSync = true } - if canSync && ifa.Sync != 0 { - tk.LogIt(tk.LogDebug, "defer resync ifa obj : %s\n", ifa.Key.Obj) + if canSync && (ifa.Sync != 0 || fsync) { + tk.LogIt(tk.LogDebug, "resync ifa obj : %s\n", ifa.Key.Obj) ifa.DP(DpCreate) } } diff --git a/pkg/loxinet/port.go b/pkg/loxinet/port.go index a6e6a3e4e..eebdbb27d 100644 --- a/pkg/loxinet/port.go +++ b/pkg/loxinet/port.go @@ -209,9 +209,12 @@ func (P *PortsH) PortAdd(name string, osid int, ptype int, zone string, p.HInfo.Link = hwi.Link p.HInfo.State = hwi.State p.HInfo.Mtu = hwi.Mtu - if !p.IsL3TunPort() && bytes.Equal(hwi.MacAddr[:], p.HInfo.MacAddr[:]) == false { + if !p.IsL3TunPort() && !bytes.Equal(hwi.MacAddr[:], p.HInfo.MacAddr[:]) { p.HInfo.MacAddr = hwi.MacAddr p.DP(DpCreate) + + tk.LogIt(tk.LogInfo, "port add - %s addr-changed\n", name) + zn.L3.IfasTicker(true) } if p.SInfo.PortType == cmn.PortReal { diff --git a/pkg/loxinet/zones.go b/pkg/loxinet/zones.go index d77357fcd..91c17ce27 100644 --- a/pkg/loxinet/zones.go +++ b/pkg/loxinet/zones.go @@ -238,6 +238,6 @@ func (z *ZoneH) ZoneTicker() { zone.Sess.SessionTicker() zone.Pols.PolTicker() zone.Mirrs.MirrTicker() - zone.L3.IfasTicker() + zone.L3.IfasTicker(false) } }