All Projects → mqliang → libipvs

mqliang / libipvs

Licence: Apache-2.0 license
Pure Go lib to work with IPVS using generic netlink socket

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to libipvs

Keepalived
Keepalived
Stars: ✭ 2,877 (+6917.07%)
Mutual labels:  netlink, ipvs
netfilter
Pure-Go Netfilter Netlink family implementation.
Stars: ✭ 51 (+24.39%)
Mutual labels:  netlink
tentacool
REST API to manage Linux networking via netlink
Stars: ✭ 63 (+53.66%)
Mutual labels:  netlink
basebox
A tiny OpenFlow controller for OF-DPA switches.
Stars: ✭ 39 (-4.88%)
Mutual labels:  netlink
OpenNetLink
Development of NetLink for open OS based on cross platform.
Stars: ✭ 17 (-58.54%)
Mutual labels:  netlink
garlic
GArLIC: GolAng LInux Connector: A Proc Connector library for go
Stars: ✭ 21 (-48.78%)
Mutual labels:  netlink
netlink-examples
Linux kernel Netlink examples inspired by "Why and How to Use Netlink Socket"
Stars: ✭ 28 (-31.71%)
Mutual labels:  netlink
wgnlpy
WireGuard + Netlink + Python
Stars: ✭ 38 (-7.32%)
Mutual labels:  netlink
ethtool
Package ethtool allows control of the Linux ethtool generic netlink interface. MIT Licensed.
Stars: ✭ 47 (+14.63%)
Mutual labels:  netlink
wgctl
Utility to configure and manage your WireGuard tunnels
Stars: ✭ 59 (+43.9%)
Mutual labels:  netlink
connect
tiny cross-platform socket API library
Stars: ✭ 46 (+12.2%)
Mutual labels:  netlink
Kube Router
Kube-router, a turnkey solution for Kubernetes networking.
Stars: ✭ 1,814 (+4324.39%)
Mutual labels:  ipvs
Sealos
一条命令离线安装高可用kubernetes,3min装完,700M,100年证书,版本不要太全,生产环境稳如老狗
Stars: ✭ 5,253 (+12712.2%)
Mutual labels:  ipvs
balanced
BalanceD is a Layer-4 Linux Virtual Server (LVS) based load balancing platform for Kubernetes.
Stars: ✭ 34 (-17.07%)
Mutual labels:  ipvs

libipvs: Pure Go lib to work with IPVS

This project provides a pure Go client to communicate with IPVS kernel module using generic netlink socket. Netlink socket are used to communicate with various kernel subsystems as an RPC system.

Go Report Card Documentation

Requirements

  • Linux platform

API

type IPVSHandle interface {
	Flush() error
	GetInfo() (info Info, err error)
	ListServices() (services []*Service, err error)
	NewService(s *Service) error
	UpdateService(s *Service) error
	DelService(s *Service) error
	ListDestinations(s *Service) (dsts []*Destination, err error)
	NewDestination(s *Service, d *Destination) error
	UpdateDestination(s *Service, d *Destination) error
	DelDestination(s *Service, d *Destination) error
}

TODO

  • IPVS state synchronization: support configuring the in-kernel IPVS sync daemon for supporting failover between IPVS routers, as done with keepalived lvs_sync_daemon_interface

Acknowledgments

  • The code is first “borrowed” from https://github.com/qmsk/clusterf, so all kudos goes @SpComb. I moved the code out into this dedicated project, with a better API, proper tests and concurrency safety, so everyone would benefit from having a good and well-tested package.

Alternatives

Other pure go implementation of IPVS that maybe useful:

Example code

package main

import (
	"fmt"
	"net"
	"syscall"

	"github.com/mqliang/libipvs"
)

func main() {
	h, err := libipvs.New()
	if err != nil {
		panic(err)
	}
	if err := h.Flush(); err != nil {
		panic(err)
	}

	info, err := h.GetInfo()
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", info)

	svcs, err := h.ListServices()
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", svcs)

	svc := libipvs.Service{
		Address:       net.ParseIP("172.192.168.1"),
		AddressFamily: syscall.AF_INET,
		Protocol:      libipvs.Protocol(syscall.IPPROTO_TCP),
		Port:          80,
		SchedName:     libipvs.RoundRobin,
	}

	if err := h.NewService(&svc); err != nil {
		panic(err)
	}

	svcs, err = h.ListServices()
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", svcs)

	dst := libipvs.Destination{
		Address:       net.ParseIP("172.192.100.1"),
		AddressFamily: syscall.AF_INET,
		Port:          80,
	}

	if err := h.NewDestination(&svc, &dst); err != nil {
		panic(err)
	}

	dsts, err := h.ListDestinations(&svc)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%#v\n", dsts)
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].