networkd-fdb.c revision 12ca818ffddb77eb6a0fabe369a5bcbf6994ff8b
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright (C) 2014 Intel Corporation. All rights reserved.
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <net/ethernet.h>
#include "conf-parser.h"
#include "util.h"
#include "netlink-util.h"
#include "networkd.h"
#include "networkd-fdb.h"
/* create a new FDB entry or get an existing one. */
const unsigned section,
/* search entry in hashmap first. */
if(section) {
if (fdb_entry) {
return 0;
}
}
/* allocate space for MAC address. */
if (!mac_addr)
return -ENOMEM;
/* allocate space for and FDB entry. */
if (!fdb_entry) {
/* free previously allocated space for mac_addr. */
return -ENOMEM;
}
/* init FDB structure. */
if (section) {
}
/* return allocated FDB structure. */
return 0;
}
int r;
r = sd_netlink_message_get_errno(m);
if (r < 0 && r != -EEXIST)
return 1;
}
/* send a request to the kernel to add a FDB entry in its static MAC table. */
int r;
/* create new RTM message */
if (r < 0)
return rtnl_log_create_error(r);
/* only NTF_SELF flag supported. */
if (r < 0)
return rtnl_log_create_error(r);
/* only NUD_PERMANENT state supported. */
if (r < 0)
return rtnl_log_create_error(r);
if (r < 0)
return rtnl_log_create_error(r);
/* VLAN Id is optional. We'll add VLAN Id only if it's specified. */
if (r < 0)
return rtnl_log_create_error(r);
}
/* send message to the kernel to update its internal static MAC table. */
if (r < 0)
return 0;
}
/* remove and FDB entry. */
if(!fdb_entry)
return;
}
}
/* parse the HW address from config files. */
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int r;
if (r < 0)
return log_oom();
/* read in the MAC address for the FDB table. */
if (ETHER_ADDR_LEN != r) {
log_syntax(unit, LOG_ERR, filename, line, 0, "Not a valid MAC address, ignoring assignment: %s", rvalue);
return 0;
}
return 0;
}
/* parse the VLAN Id from config files. */
const char *unit,
const char *filename,
unsigned line,
const char *section,
unsigned section_line,
const char *lvalue,
int ltype,
const char *rvalue,
void *data,
void *userdata) {
int r;
if (r < 0)
return log_oom();
if (r < 0)
return r;
return 0;
}