{
    "$id": "https://liske.github.io/ifstate/schema/ifstate.conf.schema.json",
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "ifstate.conf",
    "description": "IfState Configuration Schema",
    "type": "object",
    "definitions": {
        "iface-link_link": {
            "type": [
                "integer",
                "string"
            ],
            "description": "specifies a parent device name or index"
        },
        "iface-link_master": {
            "type": [
                "integer",
                "string"
            ],
            "description": "specifies a master device name or index"
        },
        "iface-link_state": {
            "type": "string",
            "description": "set device state",
            "enum": [
                "up",
                "down"
            ]
        },
        "iface-link_tun-remote4": {
            "type": "string",
            "description": "remote IPv4 address of the tunnel",
            "format": "ipv4"
        },
        "iface-link_tun-local4": {
            "type": "string",
            "description": "local IPv4 address of the tunnel",
            "format": "ipv4"
        },
        "iface-link_tun-remote6": {
            "type": "string",
            "description": "remote IPv4 address of the tunnel",
            "format": "ipv6"
        },
        "iface-link_tun-local6": {
            "type": "string",
            "description": "local IPv4 address of the tunnel",
            "format": "ipv6"
        },
        "iface-link_tun-dev": {
            "$ref": "#/definitions/iface-link_link",
            "description": "interface to use for tunnel endpoint communication"
        }
    },
    "properties": {
        "options": {
            "description": "global configuration settings",
            "type": "object"
        },
        "ignore": {
            "description": "ignore patterns to skip interface, ip address or routing objects",
            "type": "object",
            "properties": {
                "ipaddr": {
                    "description": "list of ip address prefixes to be ignored",
                    "type": "array",
                    "items": {
                        "description": "ip address with prefix length",
                        "type": "string",
                        "examples": [
                            "fe80::/10"
                        ]
                    }
                },
                "ifname": {
                    "description": "interface names matching this list of regex will be ignored",
                    "type": "array",
                    "items": {
                        "description": "regex to match interface name",
                        "examples": [
                            "^docker\\d+",
                            "^lo$",
                            "^ppp\\d+$",
                            "^veth"
                        ],
                        "type": "string"
                    }
                },
                "routes": {
                    "description": "filter routes by options",
                    "type": "object",
                    "properties": {
                        "protos": {
                            "type": "array",
                            "items": {
                                "description": "protocol number (`/etc/iproute2/rt_protos`)",
                                "type": "integer"
                            }
                        }
                    }
                }
            }
        },
        "interfaces": {
            "description": "list of interface settings (link settings and ip addresses)",
            "type": "array",
            "items": {
                "type": "object",
                "required": [
                    "name"
                ],
                "properties": {
                    "name": {
                        "description": "name of the interface",
                        "type": "string"
                    },
                    "addresses": {
                        "description": "ip addresses of the interface",
                        "type": "array",
                        "items": {
                            "type": "string",
                            "examples": [
                                "192.0.2.1",
                                "192.168.0.1/24",
                                "2001:db8::1/64"
                            ]
                        }
                    },
                    "link": {
                        "description": "link settings of the interface",
                        "type": "object",
                        "oneOf": [
                            {
                                "description": "generic interface",
                                "required": [
                                    "kind"
                                ],
                                "properties": {
                                    "kind": {
                                        "type": "string",
                                        "description": "link type",
                                        "enum": [
                                            "bond",
                                            "bridge",
                                            "gtp",
                                            "ip6tnl",
                                            "ipoib",
                                            "ipvlan",
                                            "macvlan",
                                            "macvtap",
                                            "physical",
                                            "team",
                                            "tuntap",
                                            "veth",
                                            "vrf",
                                            "vti",
                                            "vti6"
                                        ]
                                    },
                                    "master": {
                                        "$ref": "#/definitions/iface-link_master"
                                    },
                                    "state": {
                                        "$ref": "#/definitions/iface-link_state"
                                    }
                                }
                            },
                            {
                                "description": "VLAN interface",
                                "required": [
                                    "kind",
                                    "link",
                                    "vlan_id"
                                ],
                                "properties": {
                                    "kind": {
                                        "type": "string",
                                        "description": "link type",
                                        "enum": [
                                            "vlan"
                                        ]
                                    },
                                    "state": {
                                        "$ref": "#/definitions/iface-link_state"
                                    },
                                    "master": {
                                        "$ref": "#/definitions/iface-link_master"
                                    },
                                    "link": {
                                        "$ref": "#/definitions/iface-link_link"
                                    },
                                    "vlan_id": {
                                        "type": [
                                            "integer"
                                        ],
                                        "minimum": 0,
                                        "maximum": 4094,
                                        "description": "specifies the VLAN identifier to use"
                                    }
                                }
                            },
                            {
                                "description": "VXLAN interface",
                                "required": [
                                    "kind",
                                    "vxlan_id",
                                    "vxlan_link"
                                ],
                                "properties": {
                                    "kind": {
                                        "type": "string",
                                        "description": "link type",
                                        "enum": [
                                            "vxlan"
                                        ]
                                    },
                                    "state": {
                                        "$ref": "#/definitions/iface-link_state"
                                    },
                                    "master": {
                                        "$ref": "#/definitions/iface-link_master"
                                    },
                                    "vxlan_id": {
                                        "type": [
                                            "integer"
                                        ],
                                        "minimum": 0,
                                        "maximum": 16777215,
                                        "description": "specifies the VNI"
                                    },
                                    "vxlan_link": {
                                        "$ref": "#/definitions/iface-link_tun-dev"
                                    }
                                }
                            },
                            {
                                "description": "IPIP interface",
                                "required": [
                                    "kind",
                                    "ipip_remote",
                                    "ipip_local"
                                ],
                                "properties": {
                                    "kind": {
                                        "type": "string",
                                        "description": "link type",
                                        "enum": [
                                            "ipip"
                                        ]
                                    },
                                    "state": {
                                        "$ref": "#/definitions/iface-link_state"
                                    },
                                    "master": {
                                        "$ref": "#/definitions/iface-link_master"
                                    },
                                    "ipip_remote": {
                                        "$ref": "#/definitions/iface-link_tun-remote4"
                                    },
                                    "ipip_local": {
                                        "$ref": "#/definitions/iface-link_tun-local4"
                                    }
                                }
                            },
                            {
                                "description": "SIT interface",
                                "required": [
                                    "kind",
                                    "sit_remote",
                                    "sit_local"
                                ],
                                "properties": {
                                    "kind": {
                                        "type": "string",
                                        "description": "link type",
                                        "enum": [
                                            "sit"
                                        ]
                                    },
                                    "state": {
                                        "$ref": "#/definitions/iface-link_state"
                                    },
                                    "master": {
                                        "$ref": "#/definitions/iface-link_master"
                                    },
                                    "sit_remote": {
                                        "$ref": "#/definitions/iface-link_tun-remote4"
                                    },
                                    "sit_local": {
                                        "$ref": "#/definitions/iface-link_tun-local4"
                                    }
                                }
                            },
                            {
                                "description": "GRE, GRETAP interface",
                                "required": [
                                    "kind",
                                    "gre_remote",
                                    "gre_local"
                                ],
                                "properties": {
                                    "kind": {
                                        "type": "string",
                                        "description": "link type",
                                        "enum": [
                                            "gre",
                                            "gretap"
                                        ]
                                    },
                                    "state": {
                                        "$ref": "#/definitions/iface-link_state"
                                    },
                                    "master": {
                                        "$ref": "#/definitions/iface-link_master"
                                    },
                                    "gre_remote": {
                                        "$ref": "#/definitions/iface-link_tun-remote4"
                                    },
                                    "gre_local": {
                                        "$ref": "#/definitions/iface-link_tun-local4"
                                    },
                                    "gre_link": {
                                        "$ref": "#/definitions/iface-link_tun-dev"
                                    }
                                }
                            },
                            {
                                "description": "IP6GRE, IP6GRETAP interface",
                                "required": [
                                    "kind",
                                    "ip6gre_remote",
                                    "ip6gre_local"
                                ],
                                "properties": {
                                    "kind": {
                                        "type": "string",
                                        "description": "link type",
                                        "enum": [
                                            "ip6gre",
                                            "ip6gretap"
                                        ]
                                    },
                                    "state": {
                                        "$ref": "#/definitions/iface-link_state"
                                    },
                                    "master": {
                                        "$ref": "#/definitions/iface-link_master"
                                    },
                                    "ip6gre_remote": {
                                        "$ref": "#/definitions/iface-link_tun-remote4"
                                    },
                                    "ip6gre_local": {
                                        "$ref": "#/definitions/iface-link_tun-local4"
                                    },
                                    "ip6gre_link": {
                                        "$ref": "#/definitions/iface-link_tun-dev"
                                    }
                                }
                            },
                            {
                                "description": "GENEVE interface",
                                "required": [
                                    "kind",
                                    "geneve_id"
                                ],
                                "properties": {
                                    "kind": {
                                        "type": "string",
                                        "description": "link type",
                                        "enum": [
                                            "geneve"
                                        ]
                                    },
                                    "state": {
                                        "$ref": "#/definitions/iface-link_state"
                                    },
                                    "master": {
                                        "$ref": "#/definitions/iface-link_master"
                                    },
                                    "geneve_id": {
                                        "type": [
                                            "integer"
                                        ],
                                        "minimum": 0,
                                        "maximum": 16777215,
                                        "description": "specifies the VNI to use"
                                    }
                                },
                                "oneOf": [
                                    {
                                        "description": "tunnel over IPv4",
                                        "required": [
                                            "geneve_remote"
                                        ],
                                        "properties": {
                                            "geneve_remote": {
                                                "$ref": "#/definitions/iface-link_tun-remote4"
                                            }
                                        }
                                    },
                                    {
                                        "description": "tunnel over IPv6",
                                        "required": [
                                            "geneve_remote6"
                                        ],
                                        "properties": {
                                            "geneve_remote6": {
                                                "$ref": "#/definitions/iface-link_tun-remote6"
                                            }
                                        }
                                    }
                                ]
                            },
                            {
                                "description": "XFRM interface",
                                "required": [
                                    "kind",
                                    "xfrm_link"
                                ],
                                "properties": {
                                    "kind": {
                                        "type": "string",
                                        "description": "link type",
                                        "enum": [
                                            "xfrm"
                                        ]
                                    },
                                    "state": {
                                        "$ref": "#/definitions/iface-link_state"
                                    },
                                    "master": {
                                        "$ref": "#/definitions/iface-link_master"
                                    },
                                    "xfrm_link": {
                                        "$ref": "#/definitions/iface-link_tun-dev",
                                        "description": "underlying interface used to send and receive the transformed traffic"
                                    },
                                    "xfrm_if_id": {
                                        "type": [
                                            "integer"
                                        ],
                                        "minimum": 0,
                                        "maximum": 4294967295,
                                        "default": 0,
                                        "description": "lookup key to match xfrm policies"
                                    }
                                }
                            }
                        ]
                    }
                }
            }
        },
        "routing": {
            "type": "object",
            "properties": {
                "routes": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "required": [
                            "to"
                        ],
                        "properties": {
                            "dev": {
                                "type": [
                                    "integer",
                                    "string"
                                ]
                            },
                            "proto": {
                                "type": [
                                    "integer",
                                    "string"
                                ],
                                "default": "boot"
                            },
                            "realm": {
                                "type": [
                                    "integer",
                                    "string"
                                ]
                            },
                            "scope": {
                                "type": [
                                    "integer",
                                    "string"
                                ]
                            },
                            "table": {
                                "type": [
                                    "integer",
                                    "string"
                                ],
                                "default": "main"
                            },
                            "to": {
                                "type": "string"
                            },
                            "via": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        }
    }
}