Skip to content

Commit

Permalink
*: Let's use the native IFNAMSIZ instead of INTERFACE_NAMSIZ
Browse files Browse the repository at this point in the history
INTERFACE_NAMSIZ is just a redefine of IFNAMSIZ and IFNAMSIZ
is the standard for interface name length on all platforms
that FRR currently compiles on.

Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Nov 21, 2023
1 parent 77ff93b commit 07b91ca
Show file tree
Hide file tree
Showing 32 changed files with 90 additions and 96 deletions.
2 changes: 1 addition & 1 deletion babeld/babeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ babel_get_myid(void)
/* We failed to get a global EUI64 from the interfaces we were given.
Let's try to find an interface with a MAC address. */
for(i = 1; i < 256; i++) {
char buf[INTERFACE_NAMSIZ], *ifname;
char buf[IFNAMSIZ], *ifname;
unsigned char eui[8];
ifname = if_indextoname(i, buf);
if(ifname == NULL)
Expand Down
2 changes: 1 addition & 1 deletion bfdd/bfd.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ struct bfd_key {
uint16_t mhop;
struct in6_addr peer;
struct in6_addr local;
char ifname[INTERFACE_NAMSIZ];
char ifname[IFNAMSIZ];
char vrfname[VRF_NAMSIZ];
} __attribute__((packed));

Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_flowspec_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ static int bgp_fs_local_install_interface(struct bgp *bgp,
return CMD_SUCCESS;
pbr_if = XCALLOC(MTYPE_TMP,
sizeof(struct bgp_pbr_interface));
strlcpy(pbr_if->name, ifname, INTERFACE_NAMSIZ);
strlcpy(pbr_if->name, ifname, IFNAMSIZ);
RB_INSERT(bgp_pbr_interface_head, head, pbr_if);
*bgp_pbr_interface_any = false;
} else {
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_pbr.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ struct bgp_pbr_entry_main {

struct bgp_pbr_interface {
RB_ENTRY(bgp_pbr_interface) id_entry;
char name[INTERFACE_NAMSIZ];
char name[IFNAMSIZ];
};

RB_HEAD(bgp_pbr_interface_head, bgp_pbr_interface);
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -2353,7 +2353,7 @@ static int rule_notify_owner(ZAPI_CALLBACK_ARGS)
enum zapi_rule_notify_owner note;
struct bgp_pbr_action *bgp_pbra;
struct bgp_pbr_rule *bgp_pbr = NULL;
char ifname[INTERFACE_NAMSIZ + 1];
char ifname[IFNAMSIZ + 1];

if (!zapi_rule_notify_decode(zclient->ibuf, &seqno, &priority, &unique,
ifname, &note))
Expand Down
22 changes: 11 additions & 11 deletions ldpd/ldpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ struct iface_ldp_sync {

struct iface {
RB_ENTRY(iface) entry;
char name[INTERFACE_NAMSIZ];
char name[IFNAMSIZ];
ifindex_t ifindex;
struct if_addr_head addr_list;
struct in6_addr linklocal;
Expand Down Expand Up @@ -447,7 +447,7 @@ struct ldp_entity_stats {
struct l2vpn_if {
RB_ENTRY(l2vpn_if) entry;
struct l2vpn *l2vpn;
char ifname[INTERFACE_NAMSIZ];
char ifname[IFNAMSIZ];
ifindex_t ifindex;
int operative;
uint8_t mac[ETH_ALEN];
Expand All @@ -464,7 +464,7 @@ struct l2vpn_pw {
int af;
union ldpd_addr addr;
uint32_t pwid;
char ifname[INTERFACE_NAMSIZ];
char ifname[IFNAMSIZ];
ifindex_t ifindex;
bool enabled;
uint32_t remote_group;
Expand Down Expand Up @@ -496,7 +496,7 @@ struct l2vpn {
int type;
int pw_type;
int mtu;
char br_ifname[INTERFACE_NAMSIZ];
char br_ifname[IFNAMSIZ];
ifindex_t br_ifindex;
struct l2vpn_if_head if_tree;
struct l2vpn_pw_head pw_tree;
Expand Down Expand Up @@ -618,7 +618,7 @@ struct kroute {
};

struct kaddr {
char ifname[INTERFACE_NAMSIZ];
char ifname[IFNAMSIZ];
ifindex_t ifindex;
int af;
union ldpd_addr addr;
Expand All @@ -627,7 +627,7 @@ struct kaddr {
};

struct kif {
char ifname[INTERFACE_NAMSIZ];
char ifname[IFNAMSIZ];
ifindex_t ifindex;
int flags;
int operative;
Expand All @@ -645,7 +645,7 @@ struct acl_check {
/* control data structures */
struct ctl_iface {
int af;
char name[INTERFACE_NAMSIZ];
char name[IFNAMSIZ];
ifindex_t ifindex;
int state;
enum iface_type type;
Expand All @@ -656,7 +656,7 @@ struct ctl_iface {
};

struct ctl_disc_if {
char name[INTERFACE_NAMSIZ];
char name[IFNAMSIZ];
int active_v4;
int active_v6;
int no_adj;
Expand All @@ -672,7 +672,7 @@ struct ctl_adj {
int af;
struct in_addr id;
enum hello_type type;
char ifname[INTERFACE_NAMSIZ];
char ifname[IFNAMSIZ];
union ldpd_addr src_addr;
uint16_t holdtime;
uint16_t holdtime_remaining;
Expand Down Expand Up @@ -712,7 +712,7 @@ struct ctl_rt {
struct ctl_pw {
uint16_t type;
char l2vpn_name[L2VPN_NAME_LEN];
char ifname[INTERFACE_NAMSIZ];
char ifname[IFNAMSIZ];
uint32_t pwid;
struct in_addr lsr_id;
uint32_t local_label;
Expand All @@ -728,7 +728,7 @@ struct ctl_pw {
};

struct ctl_ldp_sync {
char name[INTERFACE_NAMSIZ];
char name[IFNAMSIZ];
ifindex_t ifindex;
bool in_sync;
bool timer_running;
Expand Down
7 changes: 3 additions & 4 deletions lib/if.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,7 @@ struct interface *if_lookup_by_name(const char *name, vrf_id_t vrf_id)
struct vrf *vrf = vrf_lookup_by_id(vrf_id);
struct interface if_tmp;

if (!vrf || !name
|| strnlen(name, INTERFACE_NAMSIZ) == INTERFACE_NAMSIZ)
if (!vrf || !name || strnlen(name, IFNAMSIZ) == IFNAMSIZ)
return NULL;

strlcpy(if_tmp.name, name, sizeof(if_tmp.name));
Expand All @@ -374,7 +373,7 @@ struct interface *if_lookup_by_name_vrf(const char *name, struct vrf *vrf)
{
struct interface if_tmp;

if (!name || strnlen(name, INTERFACE_NAMSIZ) == INTERFACE_NAMSIZ)
if (!name || strnlen(name, IFNAMSIZ) == IFNAMSIZ)
return NULL;

strlcpy(if_tmp.name, name, sizeof(if_tmp.name));
Expand All @@ -386,7 +385,7 @@ static struct interface *if_lookup_by_name_all_vrf(const char *name)
struct vrf *vrf;
struct interface *ifp;

if (!name || strnlen(name, INTERFACE_NAMSIZ) == INTERFACE_NAMSIZ)
if (!name || strnlen(name, IFNAMSIZ) == IFNAMSIZ)
return NULL;

RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
Expand Down
4 changes: 1 addition & 3 deletions lib/if.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ enum zebra_link_type {
FreeBSD define value in /usr/include/net/if.h.
#define IFNAMSIZ 16
*/

#define INTERFACE_NAMSIZ IFNAMSIZ
#define INTERFACE_HWADDR_MAX 20

typedef signed int ifindex_t;
Expand Down Expand Up @@ -218,7 +216,7 @@ struct interface {
To delete, just set ifindex to IFINDEX_INTERNAL to indicate that the
interface does not exist in the kernel.
*/
char name[INTERFACE_NAMSIZ];
char name[IFNAMSIZ];

/* Interface index (should be IFINDEX_INTERNAL for non-kernel or
deleted interfaces).
Expand Down
2 changes: 1 addition & 1 deletion lib/ldp_sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct ldp_igp_sync_if_state {
struct ldp_igp_sync_if_state_req {
int proto;
ifindex_t ifindex;
char name[INTERFACE_NAMSIZ];
char name[IFNAMSIZ];
};

#ifdef __cplusplus
Expand Down
10 changes: 5 additions & 5 deletions lib/mlag.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int mlag_lib_decode_mlag_hdr(struct stream *s, struct mlag_msg *msg,
}

#define MLAG_MROUTE_ADD_LENGTH \
(VRF_NAMSIZ + INTERFACE_NAMSIZ + 4 + 4 + 4 + 4 + 1 + 1 + 4)
(VRF_NAMSIZ + IFNAMSIZ + 4 + 4 + 4 + 4 + 1 + 1 + 4)

int mlag_lib_decode_mroute_add(struct stream *s, struct mlag_mroute_add *msg,
size_t *length)
Expand All @@ -108,14 +108,14 @@ int mlag_lib_decode_mroute_add(struct stream *s, struct mlag_mroute_add *msg,
STREAM_GETC(s, msg->am_i_dr);
STREAM_GETC(s, msg->am_i_dual_active);
STREAM_GETL(s, msg->vrf_id);
STREAM_GET(msg->intf_name, s, INTERFACE_NAMSIZ);
STREAM_GET(msg->intf_name, s, IFNAMSIZ);

return 0;
stream_failure:
return -1;
}

#define MLAG_MROUTE_DEL_LENGTH (VRF_NAMSIZ + INTERFACE_NAMSIZ + 4 + 4 + 4 + 4)
#define MLAG_MROUTE_DEL_LENGTH (VRF_NAMSIZ + IFNAMSIZ + 4 + 4 + 4 + 4)

int mlag_lib_decode_mroute_del(struct stream *s, struct mlag_mroute_del *msg,
size_t *length)
Expand All @@ -128,7 +128,7 @@ int mlag_lib_decode_mroute_del(struct stream *s, struct mlag_mroute_del *msg,
STREAM_GETL(s, msg->group_ip);
STREAM_GETL(s, msg->owner_id);
STREAM_GETL(s, msg->vrf_id);
STREAM_GET(msg->intf_name, s, INTERFACE_NAMSIZ);
STREAM_GET(msg->intf_name, s, IFNAMSIZ);

return 0;
stream_failure:
Expand All @@ -140,7 +140,7 @@ int mlag_lib_decode_mlag_status(struct stream *s, struct mlag_status *msg)
if (s == NULL || msg == NULL)
return -1;

STREAM_GET(msg->peerlink_rif, s, INTERFACE_NAMSIZ);
STREAM_GET(msg->peerlink_rif, s, IFNAMSIZ);
STREAM_GETL(s, msg->my_role);
STREAM_GETL(s, msg->peer_state);
return 0;
Expand Down
6 changes: 3 additions & 3 deletions lib/mlag.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct mlag_frr_status {
};

struct mlag_status {
char peerlink_rif[INTERFACE_NAMSIZ];
char peerlink_rif[IFNAMSIZ];
enum mlag_role my_role;
enum mlag_state peer_state;
};
Expand All @@ -86,7 +86,7 @@ struct mlag_mroute_add {
bool am_i_dr;
bool am_i_dual_active;
vrf_id_t vrf_id;
char intf_name[INTERFACE_NAMSIZ];
char intf_name[IFNAMSIZ];
};

struct mlag_mroute_del {
Expand All @@ -95,7 +95,7 @@ struct mlag_mroute_del {
uint32_t group_ip;
enum mlag_owner owner_id;
vrf_id_t vrf_id;
char intf_name[INTERFACE_NAMSIZ];
char intf_name[IFNAMSIZ];
};

struct mlag_msg {
Expand Down
2 changes: 1 addition & 1 deletion lib/pbr.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ struct pbr_rule {
struct pbr_filter filter;
struct pbr_action action;

char ifname[INTERFACE_NAMSIZ + 1];
char ifname[IFNAMSIZ + 1];
};

/* TCP flags value shared
Expand Down
22 changes: 11 additions & 11 deletions lib/zclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -1851,7 +1851,7 @@ int zapi_pbr_rule_encode(struct stream *s, struct pbr_rule *r)
zapi_pbr_rule_filter_encode(s, &(r->filter));
zapi_pbr_rule_action_encode(s, &(r->action));

stream_put(s, r->ifname, INTERFACE_NAMSIZ);
stream_put(s, r->ifname, IFNAMSIZ);

/* Put length at the first point of the stream. */
stream_putw_at(s, 0, stream_get_endp(s));
Expand All @@ -1875,7 +1875,7 @@ bool zapi_pbr_rule_decode(struct stream *s, struct pbr_rule *r)
if (!zapi_pbr_rule_action_decode(s, &(r->action)))
goto stream_failure;

STREAM_GET(r->ifname, s, INTERFACE_NAMSIZ);
STREAM_GET(r->ifname, s, IFNAMSIZ);
return true;

stream_failure:
Expand Down Expand Up @@ -2034,7 +2034,7 @@ bool zapi_rule_notify_decode(struct stream *s, uint32_t *seqno,
STREAM_GETL(s, seq);
STREAM_GETL(s, prio);
STREAM_GETL(s, uni);
STREAM_GET(ifname, s, INTERFACE_NAMSIZ);
STREAM_GET(ifname, s, IFNAMSIZ);

if (zclient_debug)
zlog_debug("%s: %u %u %u %s", __func__, seq, prio, uni, ifname);
Expand Down Expand Up @@ -2526,12 +2526,12 @@ static int zclient_vrf_delete(ZAPI_CALLBACK_ARGS)
static int zclient_interface_add(ZAPI_CALLBACK_ARGS)
{
struct interface *ifp;
char ifname_tmp[INTERFACE_NAMSIZ + 1] = {};
char ifname_tmp[IFNAMSIZ + 1] = {};
struct stream *s = zclient->ibuf;
struct vrf *vrf;

/* Read interface name. */
STREAM_GET(ifname_tmp, s, INTERFACE_NAMSIZ);
STREAM_GET(ifname_tmp, s, IFNAMSIZ);

/* Lookup/create interface by name. */
vrf = vrf_lookup_by_id(vrf_id);
Expand Down Expand Up @@ -2562,10 +2562,10 @@ static int zclient_interface_add(ZAPI_CALLBACK_ARGS)
struct interface *zebra_interface_state_read(struct stream *s, vrf_id_t vrf_id)
{
struct interface *ifp;
char ifname_tmp[INTERFACE_NAMSIZ + 1] = {};
char ifname_tmp[IFNAMSIZ + 1] = {};

/* Read interface name. */
STREAM_GET(ifname_tmp, s, INTERFACE_NAMSIZ);
STREAM_GET(ifname_tmp, s, IFNAMSIZ);

/* Lookup this by interface index. */
ifp = if_lookup_by_name(ifname_tmp, vrf_id);
Expand Down Expand Up @@ -3055,12 +3055,12 @@ struct interface *zebra_interface_vrf_update_read(struct stream *s,
vrf_id_t vrf_id,
vrf_id_t *new_vrf_id)
{
char ifname[INTERFACE_NAMSIZ + 1] = {};
char ifname[IFNAMSIZ + 1] = {};
struct interface *ifp;
vrf_id_t new_id;

/* Read interface name. */
STREAM_GET(ifname, s, INTERFACE_NAMSIZ);
STREAM_GET(ifname, s, IFNAMSIZ);

/* Lookup interface. */
ifp = if_lookup_by_name(ifname, vrf_id);
Expand Down Expand Up @@ -3946,7 +3946,7 @@ enum zclient_send_status zebra_send_pw(struct zclient *zclient, int command,
stream_reset(s);

zclient_create_header(s, command, VRF_DEFAULT);
stream_write(s, pw->ifname, INTERFACE_NAMSIZ);
stream_write(s, pw->ifname, IFNAMSIZ);
stream_putl(s, pw->ifindex);

/* Put type */
Expand Down Expand Up @@ -3993,7 +3993,7 @@ int zebra_read_pw_status_update(ZAPI_CALLBACK_ARGS, struct zapi_pw_status *pw)
s = zclient->ibuf;

/* Get data. */
stream_get(pw->ifname, s, INTERFACE_NAMSIZ);
stream_get(pw->ifname, s, IFNAMSIZ);
STREAM_GETL(s, pw->ifindex);
STREAM_GETL(s, pw->status);

Expand Down
4 changes: 2 additions & 2 deletions lib/zclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ struct zapi_sr_policy {
};

struct zapi_pw {
char ifname[INTERFACE_NAMSIZ];
char ifname[IFNAMSIZ];
ifindex_t ifindex;
int type;
int af;
Expand All @@ -642,7 +642,7 @@ struct zapi_pw {
};

struct zapi_pw_status {
char ifname[INTERFACE_NAMSIZ];
char ifname[IFNAMSIZ];
ifindex_t ifindex;
uint32_t status;
};
Expand Down
2 changes: 1 addition & 1 deletion ospfd/ospf_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
{
struct ospf_interface *voi;
struct interface *vi;
char ifname[INTERFACE_NAMSIZ];
char ifname[IFNAMSIZ];
struct ospf_area *area;
struct in_addr area_id;
struct connected *co;
Expand Down
Loading

0 comments on commit 07b91ca

Please sign in to comment.