Skip to content

Commit 07b91ca

Browse files
committed
*: Let's use the native IFNAMSIZ instead of INTERFACE_NAMSIZ
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]>
1 parent 77ff93b commit 07b91ca

32 files changed

+90
-96
lines changed

babeld/babeld.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ babel_get_myid(void)
242242
/* We failed to get a global EUI64 from the interfaces we were given.
243243
Let's try to find an interface with a MAC address. */
244244
for(i = 1; i < 256; i++) {
245-
char buf[INTERFACE_NAMSIZ], *ifname;
245+
char buf[IFNAMSIZ], *ifname;
246246
unsigned char eui[8];
247247
ifname = if_indextoname(i, buf);
248248
if(ifname == NULL)

bfdd/bfd.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ struct bfd_key {
193193
uint16_t mhop;
194194
struct in6_addr peer;
195195
struct in6_addr local;
196-
char ifname[INTERFACE_NAMSIZ];
196+
char ifname[IFNAMSIZ];
197197
char vrfname[VRF_NAMSIZ];
198198
} __attribute__((packed));
199199

bgpd/bgp_flowspec_vty.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ static int bgp_fs_local_install_interface(struct bgp *bgp,
547547
return CMD_SUCCESS;
548548
pbr_if = XCALLOC(MTYPE_TMP,
549549
sizeof(struct bgp_pbr_interface));
550-
strlcpy(pbr_if->name, ifname, INTERFACE_NAMSIZ);
550+
strlcpy(pbr_if->name, ifname, IFNAMSIZ);
551551
RB_INSERT(bgp_pbr_interface_head, head, pbr_if);
552552
*bgp_pbr_interface_any = false;
553553
} else {

bgpd/bgp_pbr.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ struct bgp_pbr_entry_main {
134134

135135
struct bgp_pbr_interface {
136136
RB_ENTRY(bgp_pbr_interface) id_entry;
137-
char name[INTERFACE_NAMSIZ];
137+
char name[IFNAMSIZ];
138138
};
139139

140140
RB_HEAD(bgp_pbr_interface_head, bgp_pbr_interface);

bgpd/bgp_zebra.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2353,7 +2353,7 @@ static int rule_notify_owner(ZAPI_CALLBACK_ARGS)
23532353
enum zapi_rule_notify_owner note;
23542354
struct bgp_pbr_action *bgp_pbra;
23552355
struct bgp_pbr_rule *bgp_pbr = NULL;
2356-
char ifname[INTERFACE_NAMSIZ + 1];
2356+
char ifname[IFNAMSIZ + 1];
23572357

23582358
if (!zapi_rule_notify_decode(zclient->ibuf, &seqno, &priority, &unique,
23592359
ifname, &note))

ldpd/ldpd.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ struct iface_ldp_sync {
341341

342342
struct iface {
343343
RB_ENTRY(iface) entry;
344-
char name[INTERFACE_NAMSIZ];
344+
char name[IFNAMSIZ];
345345
ifindex_t ifindex;
346346
struct if_addr_head addr_list;
347347
struct in6_addr linklocal;
@@ -447,7 +447,7 @@ struct ldp_entity_stats {
447447
struct l2vpn_if {
448448
RB_ENTRY(l2vpn_if) entry;
449449
struct l2vpn *l2vpn;
450-
char ifname[INTERFACE_NAMSIZ];
450+
char ifname[IFNAMSIZ];
451451
ifindex_t ifindex;
452452
int operative;
453453
uint8_t mac[ETH_ALEN];
@@ -464,7 +464,7 @@ struct l2vpn_pw {
464464
int af;
465465
union ldpd_addr addr;
466466
uint32_t pwid;
467-
char ifname[INTERFACE_NAMSIZ];
467+
char ifname[IFNAMSIZ];
468468
ifindex_t ifindex;
469469
bool enabled;
470470
uint32_t remote_group;
@@ -496,7 +496,7 @@ struct l2vpn {
496496
int type;
497497
int pw_type;
498498
int mtu;
499-
char br_ifname[INTERFACE_NAMSIZ];
499+
char br_ifname[IFNAMSIZ];
500500
ifindex_t br_ifindex;
501501
struct l2vpn_if_head if_tree;
502502
struct l2vpn_pw_head pw_tree;
@@ -618,7 +618,7 @@ struct kroute {
618618
};
619619

620620
struct kaddr {
621-
char ifname[INTERFACE_NAMSIZ];
621+
char ifname[IFNAMSIZ];
622622
ifindex_t ifindex;
623623
int af;
624624
union ldpd_addr addr;
@@ -627,7 +627,7 @@ struct kaddr {
627627
};
628628

629629
struct kif {
630-
char ifname[INTERFACE_NAMSIZ];
630+
char ifname[IFNAMSIZ];
631631
ifindex_t ifindex;
632632
int flags;
633633
int operative;
@@ -645,7 +645,7 @@ struct acl_check {
645645
/* control data structures */
646646
struct ctl_iface {
647647
int af;
648-
char name[INTERFACE_NAMSIZ];
648+
char name[IFNAMSIZ];
649649
ifindex_t ifindex;
650650
int state;
651651
enum iface_type type;
@@ -656,7 +656,7 @@ struct ctl_iface {
656656
};
657657

658658
struct ctl_disc_if {
659-
char name[INTERFACE_NAMSIZ];
659+
char name[IFNAMSIZ];
660660
int active_v4;
661661
int active_v6;
662662
int no_adj;
@@ -672,7 +672,7 @@ struct ctl_adj {
672672
int af;
673673
struct in_addr id;
674674
enum hello_type type;
675-
char ifname[INTERFACE_NAMSIZ];
675+
char ifname[IFNAMSIZ];
676676
union ldpd_addr src_addr;
677677
uint16_t holdtime;
678678
uint16_t holdtime_remaining;
@@ -712,7 +712,7 @@ struct ctl_rt {
712712
struct ctl_pw {
713713
uint16_t type;
714714
char l2vpn_name[L2VPN_NAME_LEN];
715-
char ifname[INTERFACE_NAMSIZ];
715+
char ifname[IFNAMSIZ];
716716
uint32_t pwid;
717717
struct in_addr lsr_id;
718718
uint32_t local_label;
@@ -728,7 +728,7 @@ struct ctl_pw {
728728
};
729729

730730
struct ctl_ldp_sync {
731-
char name[INTERFACE_NAMSIZ];
731+
char name[IFNAMSIZ];
732732
ifindex_t ifindex;
733733
bool in_sync;
734734
bool timer_running;

lib/if.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,7 @@ struct interface *if_lookup_by_name(const char *name, vrf_id_t vrf_id)
362362
struct vrf *vrf = vrf_lookup_by_id(vrf_id);
363363
struct interface if_tmp;
364364

365-
if (!vrf || !name
366-
|| strnlen(name, INTERFACE_NAMSIZ) == INTERFACE_NAMSIZ)
365+
if (!vrf || !name || strnlen(name, IFNAMSIZ) == IFNAMSIZ)
367366
return NULL;
368367

369368
strlcpy(if_tmp.name, name, sizeof(if_tmp.name));
@@ -374,7 +373,7 @@ struct interface *if_lookup_by_name_vrf(const char *name, struct vrf *vrf)
374373
{
375374
struct interface if_tmp;
376375

377-
if (!name || strnlen(name, INTERFACE_NAMSIZ) == INTERFACE_NAMSIZ)
376+
if (!name || strnlen(name, IFNAMSIZ) == IFNAMSIZ)
378377
return NULL;
379378

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

389-
if (!name || strnlen(name, INTERFACE_NAMSIZ) == INTERFACE_NAMSIZ)
388+
if (!name || strnlen(name, IFNAMSIZ) == IFNAMSIZ)
390389
return NULL;
391390

392391
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {

lib/if.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ enum zebra_link_type {
8888
FreeBSD define value in /usr/include/net/if.h.
8989
#define IFNAMSIZ 16
9090
*/
91-
92-
#define INTERFACE_NAMSIZ IFNAMSIZ
9391
#define INTERFACE_HWADDR_MAX 20
9492

9593
typedef signed int ifindex_t;
@@ -218,7 +216,7 @@ struct interface {
218216
To delete, just set ifindex to IFINDEX_INTERNAL to indicate that the
219217
interface does not exist in the kernel.
220218
*/
221-
char name[INTERFACE_NAMSIZ];
219+
char name[IFNAMSIZ];
222220

223221
/* Interface index (should be IFINDEX_INTERNAL for non-kernel or
224222
deleted interfaces).

lib/ldp_sync.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct ldp_igp_sync_if_state {
5959
struct ldp_igp_sync_if_state_req {
6060
int proto;
6161
ifindex_t ifindex;
62-
char name[INTERFACE_NAMSIZ];
62+
char name[IFNAMSIZ];
6363
};
6464

6565
#ifdef __cplusplus

lib/mlag.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ int mlag_lib_decode_mlag_hdr(struct stream *s, struct mlag_msg *msg,
9292
}
9393

9494
#define MLAG_MROUTE_ADD_LENGTH \
95-
(VRF_NAMSIZ + INTERFACE_NAMSIZ + 4 + 4 + 4 + 4 + 1 + 1 + 4)
95+
(VRF_NAMSIZ + IFNAMSIZ + 4 + 4 + 4 + 4 + 1 + 1 + 4)
9696

9797
int mlag_lib_decode_mroute_add(struct stream *s, struct mlag_mroute_add *msg,
9898
size_t *length)
@@ -108,14 +108,14 @@ int mlag_lib_decode_mroute_add(struct stream *s, struct mlag_mroute_add *msg,
108108
STREAM_GETC(s, msg->am_i_dr);
109109
STREAM_GETC(s, msg->am_i_dual_active);
110110
STREAM_GETL(s, msg->vrf_id);
111-
STREAM_GET(msg->intf_name, s, INTERFACE_NAMSIZ);
111+
STREAM_GET(msg->intf_name, s, IFNAMSIZ);
112112

113113
return 0;
114114
stream_failure:
115115
return -1;
116116
}
117117

118-
#define MLAG_MROUTE_DEL_LENGTH (VRF_NAMSIZ + INTERFACE_NAMSIZ + 4 + 4 + 4 + 4)
118+
#define MLAG_MROUTE_DEL_LENGTH (VRF_NAMSIZ + IFNAMSIZ + 4 + 4 + 4 + 4)
119119

120120
int mlag_lib_decode_mroute_del(struct stream *s, struct mlag_mroute_del *msg,
121121
size_t *length)
@@ -128,7 +128,7 @@ int mlag_lib_decode_mroute_del(struct stream *s, struct mlag_mroute_del *msg,
128128
STREAM_GETL(s, msg->group_ip);
129129
STREAM_GETL(s, msg->owner_id);
130130
STREAM_GETL(s, msg->vrf_id);
131-
STREAM_GET(msg->intf_name, s, INTERFACE_NAMSIZ);
131+
STREAM_GET(msg->intf_name, s, IFNAMSIZ);
132132

133133
return 0;
134134
stream_failure:
@@ -140,7 +140,7 @@ int mlag_lib_decode_mlag_status(struct stream *s, struct mlag_status *msg)
140140
if (s == NULL || msg == NULL)
141141
return -1;
142142

143-
STREAM_GET(msg->peerlink_rif, s, INTERFACE_NAMSIZ);
143+
STREAM_GET(msg->peerlink_rif, s, IFNAMSIZ);
144144
STREAM_GETL(s, msg->my_role);
145145
STREAM_GETL(s, msg->peer_state);
146146
return 0;

lib/mlag.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct mlag_frr_status {
6565
};
6666

6767
struct mlag_status {
68-
char peerlink_rif[INTERFACE_NAMSIZ];
68+
char peerlink_rif[IFNAMSIZ];
6969
enum mlag_role my_role;
7070
enum mlag_state peer_state;
7171
};
@@ -86,7 +86,7 @@ struct mlag_mroute_add {
8686
bool am_i_dr;
8787
bool am_i_dual_active;
8888
vrf_id_t vrf_id;
89-
char intf_name[INTERFACE_NAMSIZ];
89+
char intf_name[IFNAMSIZ];
9090
};
9191

9292
struct mlag_mroute_del {
@@ -95,7 +95,7 @@ struct mlag_mroute_del {
9595
uint32_t group_ip;
9696
enum mlag_owner owner_id;
9797
vrf_id_t vrf_id;
98-
char intf_name[INTERFACE_NAMSIZ];
98+
char intf_name[IFNAMSIZ];
9999
};
100100

101101
struct mlag_msg {

lib/pbr.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ struct pbr_rule {
138138
struct pbr_filter filter;
139139
struct pbr_action action;
140140

141-
char ifname[INTERFACE_NAMSIZ + 1];
141+
char ifname[IFNAMSIZ + 1];
142142
};
143143

144144
/* TCP flags value shared

lib/zclient.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,7 @@ int zapi_pbr_rule_encode(struct stream *s, struct pbr_rule *r)
18511851
zapi_pbr_rule_filter_encode(s, &(r->filter));
18521852
zapi_pbr_rule_action_encode(s, &(r->action));
18531853

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

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

1878-
STREAM_GET(r->ifname, s, INTERFACE_NAMSIZ);
1878+
STREAM_GET(r->ifname, s, IFNAMSIZ);
18791879
return true;
18801880

18811881
stream_failure:
@@ -2034,7 +2034,7 @@ bool zapi_rule_notify_decode(struct stream *s, uint32_t *seqno,
20342034
STREAM_GETL(s, seq);
20352035
STREAM_GETL(s, prio);
20362036
STREAM_GETL(s, uni);
2037-
STREAM_GET(ifname, s, INTERFACE_NAMSIZ);
2037+
STREAM_GET(ifname, s, IFNAMSIZ);
20382038

20392039
if (zclient_debug)
20402040
zlog_debug("%s: %u %u %u %s", __func__, seq, prio, uni, ifname);
@@ -2526,12 +2526,12 @@ static int zclient_vrf_delete(ZAPI_CALLBACK_ARGS)
25262526
static int zclient_interface_add(ZAPI_CALLBACK_ARGS)
25272527
{
25282528
struct interface *ifp;
2529-
char ifname_tmp[INTERFACE_NAMSIZ + 1] = {};
2529+
char ifname_tmp[IFNAMSIZ + 1] = {};
25302530
struct stream *s = zclient->ibuf;
25312531
struct vrf *vrf;
25322532

25332533
/* Read interface name. */
2534-
STREAM_GET(ifname_tmp, s, INTERFACE_NAMSIZ);
2534+
STREAM_GET(ifname_tmp, s, IFNAMSIZ);
25352535

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

25672567
/* Read interface name. */
2568-
STREAM_GET(ifname_tmp, s, INTERFACE_NAMSIZ);
2568+
STREAM_GET(ifname_tmp, s, IFNAMSIZ);
25692569

25702570
/* Lookup this by interface index. */
25712571
ifp = if_lookup_by_name(ifname_tmp, vrf_id);
@@ -3055,12 +3055,12 @@ struct interface *zebra_interface_vrf_update_read(struct stream *s,
30553055
vrf_id_t vrf_id,
30563056
vrf_id_t *new_vrf_id)
30573057
{
3058-
char ifname[INTERFACE_NAMSIZ + 1] = {};
3058+
char ifname[IFNAMSIZ + 1] = {};
30593059
struct interface *ifp;
30603060
vrf_id_t new_id;
30613061

30623062
/* Read interface name. */
3063-
STREAM_GET(ifname, s, INTERFACE_NAMSIZ);
3063+
STREAM_GET(ifname, s, IFNAMSIZ);
30643064

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

39483948
zclient_create_header(s, command, VRF_DEFAULT);
3949-
stream_write(s, pw->ifname, INTERFACE_NAMSIZ);
3949+
stream_write(s, pw->ifname, IFNAMSIZ);
39503950
stream_putl(s, pw->ifindex);
39513951

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

39953995
/* Get data. */
3996-
stream_get(pw->ifname, s, INTERFACE_NAMSIZ);
3996+
stream_get(pw->ifname, s, IFNAMSIZ);
39973997
STREAM_GETL(s, pw->ifindex);
39983998
STREAM_GETL(s, pw->status);
39993999

lib/zclient.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ struct zapi_sr_policy {
629629
};
630630

631631
struct zapi_pw {
632-
char ifname[INTERFACE_NAMSIZ];
632+
char ifname[IFNAMSIZ];
633633
ifindex_t ifindex;
634634
int type;
635635
int af;
@@ -642,7 +642,7 @@ struct zapi_pw {
642642
};
643643

644644
struct zapi_pw_status {
645-
char ifname[INTERFACE_NAMSIZ];
645+
char ifname[IFNAMSIZ];
646646
ifindex_t ifindex;
647647
uint32_t status;
648648
};

ospfd/ospf_interface.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ struct ospf_interface *ospf_vl_new(struct ospf *ospf,
932932
{
933933
struct ospf_interface *voi;
934934
struct interface *vi;
935-
char ifname[INTERFACE_NAMSIZ];
935+
char ifname[IFNAMSIZ];
936936
struct ospf_area *area;
937937
struct in_addr area_id;
938938
struct connected *co;

0 commit comments

Comments
 (0)